-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
45 lines (41 loc) · 1.61 KB
/
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
let fetch = require('node-fetch');
function latestGempa() {
return fetch(`https://data.bmkg.go.id/DataMKG/TEWS/autogempa.json`).then(res => {
if(res.status === 200) {
return fetch(`https://data.bmkg.go.id/DataMKG/TEWS/autogempa.json`).then(n=>n.json()).then(body => {
body.Infogempa.gempa.Shakemap = {data: body.Infogempa.gempa.Shakemap,url: `https://data.bmkg.go.id/DataMKG/TEWS/${body.Infogempa.gempa.Shakemap}`}
return body.Infogempa.gempa
})
} else {
throw new Error('Unable to fetch BMKG.GO.ID')
}
})
};
function listLastGempa() {
return fetch('https://data.bmkg.go.id/DataMKG/TEWS/gempaterkini.json').then(res => {
if(res.status === 200) {
return fetch(`https://data.bmkg.go.id/DataMKG/TEWS/gempaterkini.json`).then(n=>n.json()).then(body => {
return body.Infogempa.gempa
})
} else {
throw new Error('Unable to fetch BMKG.GO.ID')
}
})
};
function covidCountRI() {
return fetch(`https://covid19.mathdro.id/api/countries/indonesia`).then(res => {
if(res.status === 200) {
return fetch(`https://covid19.mathdro.id/api/countries/indonesia`).then(n=>n.json()).then(body => {
return body
})
} else {
throw new Error('Unable to fetch Covid19 API Stats. Retry again later.')
}
})
};
module.exports = {
latestGempa: latestGempa,
listOfTopFifteenGempa: listLastGempa,
covidCountIndonesia: covidCountRI,
version: '1.0.5'
}