HELP: Weather App: API Callback-What's Missing in My Code?

Hi I have a question on my weather app project. I have been stuck in finding a solution for api callback. Can anyone tell me why the weather description and temperature aren’t displaying? After having tinkered around, I think the problem is that api callback isn’t working. I need a lead from here to finish the project! Thank you!

What is the weatherUrl in your second JSON call?

Hi! It’s from line 19 var weatherURL = “” + lat + “&lon” + lon + “&APPID=089f42d0c4d6794ea48978cef62f55ee”; I looked up this and pass information of weather from OpenWeatherApp based on the location.

And what is with the weatherUrl on the line 4?

Add console.log(weatherUrl) before second JSON call and see what the value of weatherUrl is.

The problem is that your call to the openWeatherMap api is made before receiving the location. Functions with callback are asynchronous, the first parameter of those function make the call and the function in the second parameter is executed when you receive the callback, but the script will continue while waiting for the callback.

so right now you’re making a call to receive the location and while waiting to receice the location, you’re calling the openWeatherMap api, but weatherURL is empty beacause it’s only attributed when you receive the location.

You have to call openWeatherMap when receiving the location.
(there’s also a mistake in the url)

I tested it and it’s empty. I will find out why and study about it!

Ah, I didn’t even define the problem correctly. I will work on the code based on your advice! Thanks!

@jenovs @tommypepsi Thanks for your advice and help on solving the problem. I used the name of the city instead of using latitude and longitude and it worked!