Weather App Long and Lat


I am having trouble getting my Long and Lat variables set to the JSON Long and LAT being pulled from FCC weather API. My project is here

Getting the location from the system takes time, so getting the position is an asynchronous operation: your lat/long values are therefore undefined at the point in the program that you try to use them.

You need to do your request to the weather service in the geolocation function callback; that way JS will get the location then use the values to populate the url

Add the console right after u added data to ur variables.
Due to asynchronous operation console is executed before ur variables get the values

1 Like

Geo location callback?

apiInfo = `${userLon}&lat=${userLat}`

The first place you have this, just after the userLon and userLat, that’s where you make the call, inside the function, not outside it where you have the line repeated (delete that one, keep the first one)

1 Like

Its works, thank you!

1 Like