Skip to content

Commit 04acd7c

Browse files
author
Sv443
committed
added "amount" response property
1 parent 21109c9 commit 04acd7c

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

docs/raw/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ <h2 style="color: orangered;">By using this website and API you are agreeing to
619619
<mark>?amount=number</mark><br><br>
620620
This parameter can only be used on the "joke" endpoint.<br>
621621
If it is used, you will get a certain number of jokes in a single request.<br>
622+
If <!--%#INSERT:NAME#%--> has less jokes than demanded, it will not error out but instead send the maximum amount of jokes it can serve.<br>
622623
Maximum possible number is <!--%#INSERT:MAXJOKEAMOUNT#%--> and using an invalid value will make <!--%#INSERT:NAME#%--> default to 1.<br>
623624
The joke format will change from the default when you set the amount parameter to 2 or more.<br>
624625
<br>
@@ -634,7 +635,8 @@ <h2 style="color: orangered;">By using this website and API you are agreeing to
634635
...
635636
},
636637
...
637-
]
638+
],
639+
"amount": 10
638640
}
639641
</div></code><br>
640642
</details>

endpoints/joke.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,16 @@ const call = (req, res, url, params, format) => {
208208
{
209209
multiObj = {
210210
error: false,
211-
jokes: jokesArray
211+
jokes: jokesArray,
212+
amount: jokesArray.length || 1
212213
};
213214
}
214215
else
215216
{
216217
multiObj = {
217218
error: false,
218-
jokes: { "joke": jokesArray }
219+
jokes: { "joke": jokesArray },
220+
amount: jokesArray.length || 1
219221
};
220222
}
221223

tests/joke-endpoint.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable */
2+
13
const settings = require("../settings");
24

35
const meta = {

tools/test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
const settings = require("../settings");
1+
/* eslint-disable */
22

3+
const settings = require("../settings");
34

45

56
function getAllTests()

0 commit comments

Comments
 (0)