Skip to content
Advertisement

Data Format, how to map this object?

I’d like to map out an array from a backend API call.

This comes from a schema which currently has the format of

JavaScript

Within this, I have an object, however it looks like this for example:

JavaScript

Given the above, i’d like to map through this data on a component. I have tried to store it into a const, then map however it will error out. For example:

JavaScript

This is then passed to a component which displays each user in the card. What am I doing wrong and how should i reformat?

Advertisement

Answer

Hi the first thing i can notice from your code you declare “comapnyFull” and you are iterating over “companyMembers”

the code should be:

JavaScript

however i’m not sure that is what you are looking for, your arrays access should be:

JavaScript

or

JavaScript

if you want to iterate over one param, and get something from another param you do it like that:

JavaScript

Hope it makes it more clear

UPDATE

Based on comments member_v2 remap to array:

JavaScript

using destructure and combining in compcode

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement