Last active
March 26, 2020 19:40
-
-
Save deckarts/53d1f057a22c658eb4e4b1ed4fbc2ef4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0"> | |
<meta http-equiv="x-ua-compatible" content="ie=edge"> | |
<title>US Covid-19</title> | |
<script> | |
const getCovidStats = async() => { | |
try { | |
const response = await fetch('https://covidtracking.com/api/us'); | |
const usa = await response.json(); | |
covid19 = usa[0]; | |
} | |
catch (err) { | |
console.log(`Error: ${err}`); | |
} | |
finally { | |
markup = ` | |
Tests: ${covid19['totalTestResults']} | |
Positive: ${covid19['positive']} | |
Negative: ${covid19['negative']} | |
Hospitalized: ${covid19['hospitalized']} | |
Deaths: ${covid19['death']}` | |
document.getElementById('main').innerText = markup; | |
} | |
}; | |
getCovidStats(); | |
</script> | |
</head> | |
<body> | |
<div id="main"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment