Update
I try with try and catch block . If the error may occur it will be log to the console and it works fine
const fetchApi = async () => {
try {
const url = `https://api.openweathermap.org/data/2.5/weather?q=${search}&units=metric&appid={key}`;
const response = await fetch(url);
const res = await response.json();
setCity(res.main);
setWeather(res.weather[0].main);
setWind(res.wind);
} catch (err) {
console.log(err);
}
};
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…