I am writing my code in codesandbox and very simply trying to fetch a weather API. I have done numerous API calls in codesandbox and it has always been just fine, except this one.
I ran it in a console and it returns the data just fine too. I seriously cannot understand what is causing this? If someone could take a look and help, that would be super appreciated. Here is the code:
import React, { useState, useEffect } from "react";
const WeekContainer = () => {
const [data, setData] = useState([]);
async function getData() {
const weatherURL = `http://api.openweathermap.org/data/2.5/forecast?zip=11102&units=imperial&APPID=dcadf332823cddfb979926a1414274e8`;
const result = await fetch(weatherURL);
const a = await result.json();
console.log(a)
setData(a)
}
useEffect(() => {
getData();
}, []);
return <div>weekcontainer</div>;
};
export default WeekContainer;
Thanks for your time