Question:I’m trying to get a list of countries from an API and this is how I’m doing it.
Answer:Check the API: https://covid19.mathdro.id/api/countries
I can see the response format is:
response.json()it’s returning an object, not an array. That is why
lengthis undefined and
mapis not a function.
The list of countries you want is inside the property
For it to work you can change your code to something like:
If you have better answer, please add a comment about this, thank you!