Issue with Weather App

Hey everyone, hope y’all are doing well today.

I am having an issue with my weather app challenge but I’m not sure if it has to do with my code or my computer. If you could please take a look at my site and let me know if it shows the correct location for you. I have it set to new york by default so I could make sure all of my other code is working correctly. If it isn’t working for you please take a look at my code and let me know if you see something I missed or did incorrectly.

Thanks to all in advance.

My Weather App

The getLocation(); function completes after all other code has run. It’s is an async call so other code should be run after this completes.

I have the call to the function before all of the others now and still have the same issue.

I have a problem with the " get location " thing. What if the user doesn’t share their location?
To force the issue you can use an IP address service which returns the lat-long.
If you don’t want to do this I can help you with the standard way to do it.

See possible solution:

 navigator.geolocation.getCurrentPosition(function(pos) {
        userLat = pos.coords.latitude;
        userLng = pos.coords.longitude;
     // get the weather here
      });

I don’t mind using a IP service to find the coordinates if they chose to not share their location, however, even if I do that I’m still going to have the same issue with my function if the user does indeed share their location. You know what I mean? I just want to fix the function so that way when the user shares their location it will store the coordinates in my variables.

So did that clue above not help? :confused:

Lol, I looked at the code the first time and thought it was just a snippet of my code and wasn’t too sure as to why you stuck it there. However, after you asked if it worked I looked again and noticed your comment and yes it does indeed work by calling it from within the callback function!

Thank you very much that has been bugging the mess out of me lol!

1 Like