-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.ts
31 lines (30 loc) · 855 Bytes
/
index.ts
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
import axios from "axios";
import jokes from "./jokes.json";
class DicioJS {
async significado(word: string) {
return await axios
.get(`https://significado.herokuapp.com/meanings/${encodeURI(word)}`)
.then((response) => {
return response.data[0];
});
}
async wikipedia(word: string) {
return axios
.get(
`https://pt.wikipedia.org/api/rest_v1/page/summary/${encodeURI(word)}`,
{
httpsAgent:
"Mozilla/5.0 (Macintosh; Intel Mac OS X 11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36",
}
)
.then((response) => {
return response.data;
});
}
piada() {
const rand = Math.floor(Math.random() * jokes.features.length);
const piada = jokes.features[rand];
return piada;
}
}
export = new DicioJS();