Open Weather App Help Needed!

Open Weather App Help Needed!
0

#1

Very new at this and am looking for someone to point me in the right direction. I’m trying to get the Open Weather JSON to display like in the “JSON to HTML” example so I can use the key / value pairs to build the rest of the app. When I click the submit button, however, nothing happens and I’ve been staring at it for hours. Help!

Link to my Codepen


#2

Your problem is in the use of the forEach function. The forEach function only works on arrays and the json you get returned is not an array. In this case there is no need to loop through it. You can just acces all the properties, like: json.coords.lat. You should always open the browser console when you have an error. And if you don’t know what the returned json will look like, console.log that to the console.

If you do want to loop through everything, you can use something like this: Object.keys(json).forEach(function(key){});


#3

Thank you, Ben! This got me going in the right direction.