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.
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.