When the data is fetched from the API it returns an empty object. Here is the code below. It returns an empty object when I console.log then later brings back the object with data in it.
function App() {
const [wdata, setWdata] = useState({})
const API = "62f84860b69bddcd19d34120487d7375"
useEffect(() => {
fetch(`https://api.openweathermap.org/data/2.5/weather?lat=35&lon=139&appid=${API}`)
.then(response => response.json())
.then(resp => setWdata(resp))
.catch(error => console.log(error))
}, [Left])
console.log(wdata)
return (
<div className="App">
<Left className="left" name={wdata.sys.country} temp={wdata.main.temp} description={wdata.weather[0].description} />
<Right className="right" />
</div>
);
}