Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unable to load the data from the fake API

I am unable to load data from the fake API and I keep getting errors.

I have tried it on code sandbox.
https://codesandbox.io/s/charming-zhukovsky-lbq4n7?file=/src/Users.js

https://fakestoreapi.com/users
This is the fake API ,I am trying to get the data from. Looks like it has nested key -value pairs.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Please help me loop through this format of data.

Thanks!

>Solution :

The API seems to work as I get results. What I see is:

Uncaught Error: Objects are not valid as a React child (found: object with keys {firstname, lastname}). If you meant to render a collection of children, use an array instead.

So name is an object that contains firstname and lastname.

Try using {user.name.firstname} instead in the DOM render.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading