Skip to content

Commit

Permalink
fetch latest daily report csv file (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
Laeyoung committed Mar 22, 2020
1 parent 7486a54 commit f93a018
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions api/jhu-edu.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ const csvPath = {
recovered: 'https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Recovered.csv'
}

const fetch = require('node-fetch')
const dailyReportDir = 'https://api.github.com/repos/CSSEGISandData/COVID-19/contents/csse_covid_19_data/csse_covid_19_daily_reports'
fetch(dailyReportDir)
.then(res => res.json())
.then(json => {
const latestDailyCSV = json
.filter(file => {
return file.name.endsWith('-2020.csv')
})
.sort((a, b) => {
return -a.name.localeCompare(b.name)
})[0]

console.log(latestDailyCSV.download_url)
})

const fixedCountryCodes = require('../dataset/country-codes.json')
const iso2CountryLoc = require('../dataset/iso2-country-loc.json')

Expand Down

0 comments on commit f93a018

Please sign in to comment.