-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
61 lines (47 loc) · 2.14 KB
/
script.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//Get data from API======================================================================
const numFormat = new Intl.NumberFormat('en-EN', { maximumFractionDigits: 0 });
var host = {
method: 'GET',
headers: {
'Content-Type': 'application/json'
},
mode: 'cors',
cache: 'default'
};
let request = new Request("https://hpb.health.gov.lk/api/get-current-statistical", host);
fetch(request)
.then(function(resp) {
return resp.json();
})
.then(function(data) {
//local_new_cases
var localNewCases = data.data.local_new_cases;
document.getElementById('1').innerHTML = numFormat.format(localNewCases);
//local_active_cases
var localActiveCases = data.data.local_active_cases;
document.getElementById('2').innerHTML = numFormat.format(localActiveCases);
//local_total_cases
var localTotalCases = data.data.local_total_cases;
document.getElementById('3').innerHTML = numFormat.format(localTotalCases);
//local_deaths
var localDeaths = data.data.local_deaths;
document.getElementById('4').innerHTML = numFormat.format(localDeaths);
//local_recovered
var localRecovered = data.data.local_recovered;
document.getElementById('5').innerHTML = numFormat.format(localRecovered);
//global_new_cases
var globalNewCases = data.data.global_new_cases;
document.getElementById('6').innerHTML = numFormat.format(globalNewCases);
//global_total_cases .replace(/,/g, '')
var globalTotalCases = data.data.global_total_cases;
document.getElementById('7').innerHTML = numFormat.format(globalTotalCases);
//global_deaths
var globalDeaths = data.data.global_deaths;
document.getElementById('8').innerHTML = numFormat.format(globalDeaths);
//global_recovered
var globalRecovered = data.data.global_recovered;
document.getElementById('9').innerHTML = numFormat.format(globalRecovered);
//update_date_time
var updateDateTime = data.data.update_date_time;
document.getElementById('date&time').innerHTML = updateDateTime;
});