covid-19-api
covid-19-api copied to clipboard
Daily Overview of Country
Would it be possible to display the daily statistics also sorted by country. My suggestion would be /countries/[country]/daily/[date] This would be extremely handy for detail pages that only need the data from one country and would save a lot of overhead and be sorted in such a use case. Thanks a lot.
My current approach for that is as follow:
for (let i = daysToFetch; i > 0; i -= 1) {
const data = await fetch(`${API_URL}/daily/${lightFormat(subDays(new Date(), i), 'MM-dd-yyyy')}`).then(data => data.json());
}
Not ideal, as it is not handled by the API, but it works.
My current approach for that is as follow:
for (let i = daysToFetch; i > 0; i -= 1) { const data = await fetch(`${API_URL}/daily/${lightFormat(subDays(new Date(), i), 'MM-dd-yyyy')}`).then(data => data.json()); }Not ideal, as it is not handled by the API, but it works.
@vitorboccio - Can you elaborate more on how you solved the workaround
@jephjohnson essentially the workaround is looping through the dates in a backwards way and pushing the result to an array. so in this loop above what it is doing is today today -1 today -2 today -3 etc. As I mentioned, its not ideal, thanks a while to load all the data, but it works. Ideally we should get those results from an API level, but thats what we have for now.
Yes, that's how I solved the issue. But I still think, that many other people dealing with this issue would be thankful, if there would be a feature solving this in the actual API.