2021年3月23日星期二

Issues displaying nested api data in React Application

I am doing a react application and I want to fetch data from an api using the useEffect hook. I am receiving the data, but I am having trouble when trying to display 1 of the items in the received object. I have no problem displaying the other items from the data that I want.

When I look at the returned data in the console I see that the property I am trying to display (and gives me error) is actually object nested inside an array.

The error that I get is "TypeError: Cannot read property '0' of undefined"

I think that the problem is that not all data is loaded in the time when it renders, but not sure how to handle this. The problem is the "coinData.description[0]". Is my approach correct

Here is my component: Componet First Part Compoent Second Part

The problem is on row 36 in the second picture

Thanks in advance !

https://stackoverflow.com/questions/66771224/issues-displaying-nested-api-data-in-react-application March 24, 2021 at 05:00AM

没有评论:

发表评论