Witam. Tworze reactowy program do łączenia się z API pogodowym: https://openweathermap.org/current. Chciałbym się spytać o jakąś drobną radę w jaki sposób zwrócić te dane dalej.
let forecast = {
searchWeather(city) {
return fetch(`api.openweathermap.org/data/2.5/weather?q=${city}&APPID=${apiKey}`)
.then(response => {
if (response.ok) {
return response.json();
}
})
.then(jsonResponse => {
return [{
id: jsonResponse.id,
name: jsonResponse.name,
temp: jsonResponse.main.temp,
temp_max: jsonResponse.main.temp_max,
temp_min: jsonResponse.main.temp_min
}]
})
}
}