Never mind. Have been overthinking it again.
XMLHttpRequest object or jQuery’s
$.ajax(), then it will respond with a JSON which includes the user’s location information.
Armed with that, you can make a new request to your weather api with the city name in your query string. Something like:
“https://someweatherAPI/data/q=” + cityFromFirstRequest + “&API_KEY=som ekey”
This should return the weather information for the particular location
Weather underground API has an autoip feature you might be interested in.
I used https://ipapi.co. You don’t need a users IP to get the JSON response. You can make a request like this: https://ipapi.co/json. That will return the ip and gps coordinates. You’ll also need to consider using JSONP for the weather. You’ll know if you’re getting any Access-Control-Allow-Origin errors.