I m creating React app, and I am using http://www.omdbapi.com/ which gives you an object, I find out that to loop over an object. Little googling I was able to create this
{Object.keys(movies).map((key, index)=>{
return(
<div key={index}>
{/* {key}: {JSON.stringify(movies[key].Title)} */}
{key === "Poster"? <img src={movies[key]} alt="hello"/> : ""}
{key === "Title"? <h1>{movies[key]}</h1>: ""}
</div>
)
})}
but the page prints a lot of divs, not sure why.
I m very comfortable with an array but this is confusing me.