-
Notifications
You must be signed in to change notification settings - Fork 5
/
jokes.js
37 lines (33 loc) · 978 Bytes
/
jokes.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
//import axios from "axios";
// module.exports = {
// getOne: function () {
// return new Promise((resolve, reject) => {
// fetch('http://api.icndb.com/jokes/random')
// .then(res => res.json())
// .then(data => {
// resolve(data.value.joke);
// })
// });
// }
// }
export const jokes = {
getOne: function () {
return new Promise((resolve, reject) => {
fetch('http://api.icndb.com/jokes/random')
.then(res => res.json())
.then(data => {
resolve(data.value.joke);
})
});
}
}
// export const jokes = {
// getOne: function () {
// return new Promise((resolve, reject) => {
// axios.get('http://api.icndb.com/jokes/random')
// .then(res => {
// resolve(res.data.value.joke);
// });
// });
// }
// }