Weather App Long and Lat

Weather App Long and Lat
0.0 0

#1

Hello,

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


#2

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


#3

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


#4

Geo location callback?


#5
apiInfo = `https://fcc-weather-api.glitch.me/api/current?lon=${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)


#6

Its works, thank you!