I have an API which originally returned an array of objects with no key for each object like this:
[
{
"id": 4311,
"title": "C43- Miami Bow Cabinet Handles High Quality Stainless Steel (Polished) Handles",
"liked": false
},
{
"id": 2235,
"title": "C43- Miami Bow Cabinet Handles High Quality Stainless Steel (Brushed) Handles",
"liked": false
}
]
However it would help my app a lot if I could store this data with the id as the key for each nested object, I have updated my API to return data like this:
{
"2235": {
"title": "C43- Miami Bow Cabinet Handles High Quality Stainless Steel (Brushed) Handles",
"liked": false
},
"4311": {
"title": "C43- Miami Bow Cabinet Handles High Quality Stainless Steel (Polished) Handles",
"liked": false
}
}
However now I get an error from react - 'props.posts.map is not a function'
I cant understand what has changed to the data, doesnt redux assign a numerical key to each object if one isnt set anyways?