File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 11const api = "https://pomber.github.io/covid19/" ;
22const DATA = api + "timeseries.json" ;
3+ const FLAGS = api + "countries.json" ;
34
45import fetch from "node-fetch" ;
56
67export 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 {
You can’t perform that action at this time.
0 commit comments