I have a React component that has to retrieve the items of an array containing objects that comes from an API. The array, favorites
, is structured with items like this:
0:Object
_id:Object
ObjectId:"5db9cd4a1a088e7756516889"
where each of the items hold the id for a specific movie within a collection called movies
. I have been trying to use map
to get the data from this array with this piece of code:
{favorites.map(favorite =>
(<li key={favorite}>
<p className="favorites">
{JSON.parse(localStorage.getItem('movies')).find(movie => movie._id === favorite).title}
I have been failing miserably because I looked so much into this code. Could any of you throw some light in it? Any help is appreciated. Thanks in advance