Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
Quiero obtener los datos de una función y pasarlos a una URL de búsqueda para obtener datos de la ciudad.

Este es el código en el que estoy trabajando a continuación. Estoy tratando de obtener los datos de latitud y longitud de la primera URL, para poder pasarlos a una nueva solicitud de recuperación que toma la latitud y la longitud para obtener datos meteorológicos en una ciudad con un pronóstico de 5 días. Pero no estoy seguro de cómo llamar a los datos de una función y pasarlos como una cadena en la URL.

 let weather = { "apiKey": "", "city": " ", fetchWeather: function(city) { // this fetch will call the api to grab the Lon and lat, using the function displayLatlon fetch("https://api.openweathermap.org/data/2.5/weather?q=" + city + "&units=imperial&appid=" + this.apiKey) .then(response => response.json()) .then(data => this.displaylatlon(data)) // This fetch will use the API to grab the weather conditions for the city based on it's lat and lon fetch("https://api.openweathermap.org/data/3.0/onecall?lat=" + **lat** + "&lon=" + **lon** + "&exclude=hourly,daily&appid=" + this.apiKey) .then(response => response.json()) .then(weatherData =>console.log(weatherData)) }, // Function to grab the latitude and longitude of the city **displaylatlon: function(data) { const {lat, lon} = data.coord const{temp} = data.main** console.log(lat, lon) } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Apenas:

 fetch("https://api.openweathermap.org/data/2.5/weather?q=" + city + "&units=imperial&appid=" + this.apiKey) .then(response => response.json()) .then(data => { const {lat, lon} = data.coord; return fetch("https://api.openweathermap.org/data/3.0/onecall?lat=" + **lat** + "&lon=" + **lon** + "&exclude=hourly,daily&appid=" + this.apiKey) }) .then(response => response.json()) .then(weatherData =>console.log(weatherData))

Puede abrir un alcance {} para usar varias líneas de código.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!