Search code examples
javascriptnode.jsjsonapiopenweathermap

How to get property from API Response in Node JS?


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?


Solution

  • 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