-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
29 lines (25 loc) · 1005 Bytes
/
main.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
var country = document.getElementById('country');
var active = document.getElementById('active');
var recovered = document.getElementById('recovered');
var death = document.getElementById('death');
var total = document.getElementById('total');
var lastupdate = document.getElementById('last-update');
const getCovidData = async () => {
try {
const res = await fetch('https://api.covid19india.org/data.json');
const actualData = await res.json();
console.log(actualData.statewise);
country.innerHTML = "INDIA"
active.innerHTML = actualData.statewise[0].active;
recovered.innerHTML = actualData.statewise[0].recovered;
death.innerHTML = actualData.statewise[0].deaths;
lastupdate.innerHTML = actualData.statewise[0].lastupdatedtime;
total.innerHTML = actualData.statewise[0].confirmed;
}
catch (err) {
console.log(err);
}
}
document.addEventListener('DOMContentLoaded', function () {
getCovidData();
})