I'm using axios and redux for an api request that returns a response.data which is an array of objects.
My action reducer is as follows:
export default function(state = [], action) {
switch (action.type) {
case FETCH_USERS:
console.log(action.payload.data)
return { ...state, users: action.payload.data };
}
return state;
}
The console.log returns this in the chrome console
[object, object]
My problem arises to how I can map the data of objects. I tried the following where I mapped the array. (Users is the prop of the object array.)
....
{this.props.users.map(this.renderUser)}
...
renderUser(user) {
return (
<tr>
<td> {user.contact_name}</td>
<td> {user.contact_email}</td>
</tr>
);
}
When I use the React console to check my props i get the following:
users: {...}
users:
0:{...}
1:{...}
I'm not sure how to map the objects to html. Would it be better if I converted it to string and mapped that? My mapping appears blank.