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.

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.


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

Leave a Reply