fetch(api)
.then(response => response.json())
.then(data => {
this.setState({
locationName: data.name,
temperature: data.main.temp,
weatherDescription: data.weather[0].description,
isLoading: false,
})
})
.catch(error=> { console.log(err) });
вы можете использовать catch()
с fetch API