alexa
Facebook
Twitter
LinkedIn
Instagram
Whatsapp
Call Now
Quick Inquiry

Uncaught TypeError: Cannot read properties of null (reading '0') when fetch the API link in react.js ?

Uncaught TypeError: Cannot read properties of null (reading '0') when fetch the API link in react.js ?

As receiving api response and setting state is asynchronous, you need to check that the state datas is not undefined, just change the line to:

 if(datas && datas.length>0)
   console.log(datas[0]);

13 0
7

Write a Comments


* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online