Can ayneone please help me out with my problem it would be great.
I wanted to get current weather and 5 days forecast data to use in one weather application but iam unable to use "l1" and "l2" values for latitude and longitude asked in onecall api.
key:"your api key",
getweather(city){
fetch(`https://api.openweathermap.org/data/2.5/forecast?
q=${city}&appid=${this.key}&units=metric`)
.then(res => res.json())
.then(data =>
{weather.latdata(data),weather.longdata(data)})
},
getdaily(data){
fetch(`https://api.openweathermap.org/data/2.5/onecall?
lat=${lat}&lon=${lon}&exclude=hourly,minutely,alerts&appid=${this.key}&
units=metric`)
.then(res => res.json())
.then(data => this.display(data))
},
display(data){
const{temp,humidity}=data.current;
const{icon,description}=data.current.weather[0];
console.log(temp,icon,humidity,description);
},
latdata(data){
l1=data.city.coord.lat;
console.log(l1);
},
longdata(data){
l2=data.city.coord.lon;
console.log(l2);
},
}
weather.getdaily();
weather.getweather("mumbai"); ```