COVID-19 data

Por Sourcerers | Actualizada hace 5 meses | Data

9.8 / 10



Nivel de servicio


Volver a todas las conversaciones

Problem with getting API data using arguments set dynamically

hace un año


I am building a function to grab the getDataByCountryCode, but want to do so dynamically so I can grab and display data for any country and date entered.


The 1st line will render all the data for the fixed date and the fixed country including the info for their provinces.
The 2nd line renders the data for the proper country-- but doesn’t provide any provinces.
****Note, I am not running both of those together, swapped them out.

I’ve used the dynamic arguments in another call using only country/country code - no date…end it works as it should, it returns all the data for that country${country}

I’m not seeing the why it doesn’t work with doing the same with the api for dailyReportByCountryCode

Any thoughts?

this is the full code for fetching dailyReportByCountryCode:

async function fetchCovidStates(date, country) {
	const response = await fetch(
			method: 'GET',
			headers: {
				'x-rapidapi-host': '',
				'x-rapidapi-key': '1978ddeb10msh1004486a6040eefp1d080ejsnf92e9b1ba7d7',
	const results = await response.json();
	return results;

async function fetchAndDisplayState(date, country) {
	const data = await fetchCovidStates(date, country);


this is the call with the daily date entered dynamically and the country entered in per the call:

const today = new Date(); 
const todayDate = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
setTimeout(function() {
	fetchAndDisplayState(todayDate, 'usa')
}, 3000);

Any thoughts to where my error is with this api when I have it working with the api getLatestCountryDataByName?

Thank you,

Gramzivi commented hace un año

We have currently errors on daily report endpoints (I hope we will fix it till the end of the week)

lauraleerdh commented hace un año

Thank you.
I’ve also noted that when coding in a date to select, not all dates render data. Some dates render 0. Not sure if that error has also occurred for you or is a result of what you are all working on.

Thank you for the work you do.

Únase a la conversación, añada un comentario a continuación:

Inicie sesió/Regístrese para publicar nuevos comentarios
Valoración: 3.3 - Votos: 18