project_corona_tracker
project_corona_tracker copied to clipboard
unhandled Rejection (TypeError): Cannot read property 'length' of undefined
After working on fetchDailyData I am getting this error.
React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.
in Chart (at App.js:24)
in div (at App.js:22)
in App (at src/index.js:6)
Bro. I have the same issue. This is because the api/daily is not working and it's not returning any response. So you are getting that length error. You can check in the network tab of the developer console. There is nothing wrong in our code
Bro, Use this in your Api.js
export const fetchDailyData = async () => {
try {
const { data } = await axios.get(https://api.covidtracking.com/v1/us/daily.json
);
const modifiedData = data.map((dailydata) => ({
confirmed: dailydata.positive,
deaths: dailydata.death,
date: dailydata.date
}))
return modifiedData;
}
catch (error) {
console.log(error);
}
}
For Fetching Daily Data of United States use this api https://api.covidtracking.com/v1/us/daily.json
Issue has been resolved in the mathdroid API.