¿Alguien puede ayudarme con mi problema? Sería genial.
Quería obtener el clima actual y los datos de pronóstico de 5 días para usar en una aplicación meteorológica, pero no puedo usar los valores "l1" y "l2" para la latitud y la longitud solicitados en 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"); ```