Home > Net >  How to get property from API Response in Node JS?
How to get property from API Response in Node JS?

Time:02-04

I have an API in node JS that calls another API - openWeatherMap. This is my postman response when i call the weather API: enter image description here

But this response brings every parameters in the API and I want to show the user for example the temp.min. How can I do this?

CodePudding user response:

you can access to json Object values with thier keys, for example:

response.body.list[0].main.temp_min

CodePudding user response:

You should use 'Dot Notation' to access the required object property. Refer to the MDN Docs or a resource like W3 for more information on how to use this.

In your case, you could declare a variable equal to the property you wish to access:

minTemp = response.body.list[0].main.temp_min
  •  Tags:  
  • Related