project_cryptoverse icon indicating copy to clipboard operation
project_cryptoverse copied to clipboard

TypeError: Cannot read properties of undefined (reading 'total')

Open AlexMuia31 opened this issue 3 years ago • 14 comments

× TypeError: Cannot read properties of undefined (reading 'total') Homepage src/components/Homepage.jsx:23

23 | <Col span={12}><Statistic title="Total Cryptocurrencies" value={globalStats.total} /></Col> That's an erroe in HomePage.jsx

What could be the solution? Even the hosted project doesn't load

AlexMuia31 avatar Nov 09 '21 14:11 AlexMuia31

The coinranking API is down...status code 503

AlexMuia31 avatar Nov 09 '21 16:11 AlexMuia31

They are migrating to V2 api. It was planned to be down today. I am trying to use the temporary V2 migration api and it works fine just putting this in the browser: https://api.coinranking.com/v2/migration/coins But, in my app I am getting this response: image

arasouli91 avatar Nov 10 '21 02:11 arasouli91

Same issue have solved it?

Arif-arsh avatar Nov 13 '21 18:11 Arif-arsh

Yes right now the API is back up and running

On Sat, 13 Nov 2021, 21:50 Mohd Arif Ansari, @.***> wrote:

Same issue have solved it?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/adrianhajdin/project_cryptoverse/issues/17#issuecomment-968117127, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMNBKUHOFM4SAFSNV75DU7LUL2XPVANCNFSM5HVNLLLA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

AlexMuia31 avatar Nov 13 '21 18:11 AlexMuia31

Still I am getting the same error how to fix it?

Arif-arsh avatar Nov 13 '21 18:11 Arif-arsh

I am getting undefined (reading 'total')

Arif-arsh avatar Nov 13 '21 18:11 Arif-arsh

Do you have this part? if (isFetching) return "Loading . . .";

AlexMuia31 avatar Nov 13 '21 18:11 AlexMuia31

yes I have it still getting the same error

Arif-arsh avatar Nov 13 '21 19:11 Arif-arsh

I'm having the undefined error as well... there seems to be some kind of API error with RapidAPI and the returned object.

There are several posts on StackOverflow about using the Fetch method but I couldn't get it to work.

aindriu80 avatar Nov 15 '21 15:11 aindriu80

Has anyone had any luck getting this to work?

ParkerM2 avatar Nov 21 '21 05:11 ParkerM2

Add a question mark before the total. Something?.total it worked for me!

Arif-arsh avatar Nov 28 '21 16:11 Arif-arsh

Add a question mark before the total. Something?.total it worked for me!

Yeah by doing this I am able to see my window but value displayed in front of Total Cryptocurrencies is 0.How to resolve this?

ishitamittal1210 avatar Dec 15 '21 07:12 ishitamittal1210

Add a question mark before the total. Something?.total it worked for me!

Yeah by doing this I am able to see my window but value displayed in front of Total Cryptocurrencies is 0.How to resolve this?

I have it working on mine if you want to look at the code here -> https://github.com/ParkerM2/Crypto-Site/blob/main/src/components/HomePage.jsx

  • If that doesn't work for you I would make sure you are getting a response from the API, it could be your ENV file isn't set up properly or your API codes from RAPID API aren't returning a response if I had to guess

ParkerM2 avatar Dec 15 '21 16:12 ParkerM2

I think you guys are discussing bout this globalStats.total.

My opinion:

  • check whether the api returned the response properly by doing console.log(globalStats)

someshkrish avatar Feb 02 '22 06:02 someshkrish