project_corona_tracker icon indicating copy to clipboard operation
project_corona_tracker copied to clipboard

unhandled Rejection (TypeError): Cannot read property 'length' of undefined

Open MERCERNYC opened this issue 4 years ago • 3 comments

After working on fetchDailyData I am getting this error. Screen Shot 2020-10-08 at 8 59 27 AM 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)

MERCERNYC avatar Oct 08 '20 13:10 MERCERNYC

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

shaikhreza43 avatar Oct 12 '20 06:10 shaikhreza43

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

shaikhreza43 avatar Oct 12 '20 06:10 shaikhreza43

Issue has been resolved in the mathdroid API.

zpreston123 avatar Oct 16 '20 22:10 zpreston123