Home > Back-end >  How to fetch API with a 0 in the JSON
How to fetch API with a 0 in the JSON

Time:04-18

I am trying to fetch an API in React.JS with different data on it. However I am unable to fetch anything that has a number in it.

enter image description here

For example I am able to fetch the temperature in an API by doing data.main.temp or the humidity by doing data.main.humidity. How can I do the same for weather.0.description, since instead I get errors.

CodePudding user response:

This will do the trick weather[0].description (Get value relevant to 0th index of the array)

CodePudding user response:

Use weather[0].id or weather[0].main

  • Related