Get all the values from an array of objects

const BlogList = ({ list }) => {
 
  return (
    <div className="blog-list">
      {
	
  <ul>
  {list && list.posts && Object.keys(list.posts).map((issue, i) => 
 (
  <li key={i} >
     <img src= {list.posts[0].thumbnail_image} alt="" />
     Issue number: {list.posts[0].likes}

    
  </li>
))}
</ul>

}
    </div>
  );

};

I want to print all thumbnail_image because the above code it’s giving me only one image multiple times but I need to display each image of objects .

Without knowing what the data you are mapping looks like it’s a little hard to help.

This list.posts[0] seems to suggest posts is an array, but this Object.keys(list.posts) seems to suggest it’s an object you are turning into an array of keys.

If list.posts is an array and you do Object.keys(list.posts) you will just get an array of indexes. If list.posts is an array of objects you just want to loop the array and use each object inside the map.

Please post the data structure you are using so we can see it.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.