I'm struggling to pass a URL variable through the API fetch and I can't seem to retrieve any results. As a newcomer to Javascript, any help is greatly appreciated.
//Get IP address
fetch('https://extreme-ip-lookup.com/json/')
.then((eip) => {
return eip.json();
}).then((eip) => {
document.getElementById('ip').value = eip.query;
var myip = document.getElementById('ip').value;
var url = "https://api.pray.zone/v2/times/today.json?ip=" + myip;
})
//Get City
fetch(url)
.then((res) => {
return res.json();
}).then((res) => {
document.getElementById('city').value = res.results.location.city;
})
While I am able to obtain the IP address successfully, retrieving the city information seems to be posing a challenge for me.