Skip to content

Instantly share code, notes, and snippets.

@deckarts
Last active March 26, 2020 19:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save deckarts/53d1f057a22c658eb4e4b1ed4fbc2ef4 to your computer and use it in GitHub Desktop.
<!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