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.
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