Tengo esta función (es una función de búsqueda) y la necesito para devolver una nueva URL de API (usando la misma variable de API). ¿Qué no estoy entendiendo aquí?
var generateUrl = function(city) { var apiUrl = "https://api.openweathermap.org/data/2.5/weather?q=" + city + "&units=imperial&exclude=minutely,hourly,daily,alerts" + apiKey; var response = fetch(apiUrl).then(function(response){ response.json().then(function(data) { apiUrl = "https://api.openweathermap.org/data/2.5/onecall?lat=" + data.coord.lat + "&lon=" + data.coord.lon + "&exclude=minutely,hourly,alerts&units=imperial" + apiKey; }); }); return apiUrl; }