Help with my weather app: setting latitude and longitude as variables


After many days (weeks?) of pulling my hair out I FINALLY got the whole JSON/API stuff working for my weather App. Yay! Now the only functional thing I’m struggling with is getting the latitude and longitude.

I can get them to display, but can’t set them as variables that my other function can use. I know I have set them as specific numbers further down, but if I delete those the whole function fails.

Any tips?

I’ve managed to get it working by putting my whole “ready” function inside the geolocation function…I can’t help but feel there is a neater way to do this though. Updated pen is here

I did it the same way as you but i used for fetching location. I don’t see anything bad in nesting.