See below code:
I used Javascript to fetch latitude and longitude for displaying city name using Google-API. After successfully get lat and long when i call Google API just after below given API it will not displaying results.
if (navigator.geolocation){
navigator.geolocation.getCurrentPosition(position=>{
lat=position.coords.latitude;
long=position.coords.longitude;
const api=`https://cors.io/?https://api.darksky.net/forecast/API-KEY/${lat},${long}`;
fetch(api).then(response=>{return response.json()})
.then(data=> { console.log(data)
const {temperature}=data.currently
let celsius=(temperature-32)*(5/9)
alert(celsius)
})
//
})
}