Answer the question
In order to leave comments, you need to log in
How can you use the map array method if response is an object?
I make a request to the server
And I get the following response from the server (I get an object):
{"data": [
{
"id":20,
"title":"people",
"created_at":"2020-01-15 05:30:10",
"updated_at":"2020-01-15 05:30:10"
}
]
}
export default ({dataAttribute}) => (
<table className="table">
<thead>
<tr>
<th></th>
<th>id</th>
<th>title</th>
<th>created_at</th>
<th>updated_at</th>
</tr>
</thead>
<tbody>
{dataAttribute.map(item => (
<tr key={item.id}>
<td>{item.id}</td>
<td>{item.title}</td>
<td>{item.created_at}</td>
<td>{item.updated_at}</td>
</tr>
))}
</tbody>
</table>
);
{dataAttribute.map(item => (
{Object.keys(dataAttribute).map(item => (
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question