Skip to content

Commit 66cb410

Browse files
committed
Step 11
1 parent 8a03641 commit 66cb410

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pages/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
const api = "https://pomber.github.io/covid19/";
22
const DATA = api + "timeseries.json";
3+
const FLAGS = api + "countries.json";
34

45
import fetch from "node-fetch";
56

67
export async function getStaticProps() {
7-
const response = await fetch(DATA);
8-
const data = await response.json();
8+
const [data, flags] = await Promise.all([
9+
fetch(DATA).then((r) => r.json()),
10+
fetch(FLAGS).then((r) => r.json()),
11+
]);
912
const countries = Object.keys(data);
1013
const aCountry = data[countries[0]];
1114
const { date } = aCountry[aCountry.length - 1];
1215
const rows = countries
1316
.map((country) => {
1417
const { deaths } = data[country].find((r) => r.date === date);
15-
return { country, deaths };
18+
const flag = flags[country]?.flag || "❓";
19+
return { country, deaths, flag };
1620
})
1721
.filter((r) => r.deaths > 8);
1822
return {

0 commit comments

Comments
 (0)