-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
47 lines (33 loc) · 863 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"use strict";
const axios = require("axios");
const baseUrl = "http://api.icndb.com/";
function _callAxios(url) {
return axios.get(url);
}
function getRandomJoke() {
const url = baseUrl+"jokes/random/";
return _callAxios(url);
}
function getRandomJokes(number) {
const url = baseUrl+"jokes/random/"+number;
return _callAxios(url);
}
function getJoke(id) {
const url = baseUrl+"jokes/"+id;
return _callAxios(url);
}
function getNumberOfJokes() {
const url = baseUrl+"jokes/count/";
return _callAxios(url);
}
function getCategories() {
const url = baseUrl+"categories";
return _callAxios(url);
}
// export the module
module.exports = {
getRandomJoke: getRandomJoke,
getRandomJokes: getRandomJokes,
getNumberOfJokes: getNumberOfJokes,
getCategories: getCategories
};