I'm trying to make a fetch request for COVID data in my React Native app but each time I try to inspect the response, the console outputs undefined for the json
variable:
const [isLoading, setLoading] = useState(true);
const [data, setData] = useState({});
useEffect(() => {
fetch("https://api.covid19api.com/summary")
.then((response) => {
response.json();
})
.then((json) => {
console.log("json.. " + json);
setData(json);
})
.catch((error) => console.error(error))
.finally(() => setLoading(false));
}, []);