I have a JSON type that I will put the image of below. I want to add all the movies in it to the home page one by one, but the console is always
Uncaught (in promise) TypeError: can't access property "map", film.Search is undefined
Uncaught (in promise) TypeError: can't access property 0, item.Search is undefined
I don’t know the reason for these errors. Movies are not added to the home page. Thanks in advance for your answers.
displayResults(film) {
let fiks = film.Search.map((item, index) => {
return `
<div class="film-card">
<div class="film-poster">
<img src="${item.Search[index][index].Poster == "N/A" ? "https://blog.rahulbhutani.com/wp-content/uploads/2020/05/Screenshot-2018-12-16-at-21.06.29.png" : item.Search[index].Poster}"
alt="${item.Search[index].Title == "N/A" ? "Name Not Found" : item.Search[index].Title}">
</div>
<div class="film-info">
<div class="favorite-btn hide"><i class="fas fa-star"></i></div>
<div class="favorite-btn"><i class="far fa-star"></i></div>
<div class="film-description">
<h3>${item.Search[index].Title == "N/A" ? "Name Not Found" : item.Search[index].Title}</h3>
<p class="film-story">
${item.Search[index].Plot == "N/A" ? "Description Not Found" : item.Search[index].Plot}
</p>
<p class="film-artist">
Actors: <span>${item.Search[index].Actors == "N/A" ? "Actors Not Found" : item.Search[index].Actors}</span>
</p>
<p class="film-director">Director: <span>${item.Search[index].Director == "N/A" ? "Direcotr Not Found" : item.Search[index].Director}</span></p>
</div>
<div class="film-property">
<span class="film-imdb-rates">${item.Search[index].imdbRating == "N/A" ? "NaN" : item.Search[index].imdbRating}/10 <code> </code> <span class="rate-data-company"><em>by</em>
IMDB</span>
</span>
<span class="film-vision-date">Release Date: <span>${item.Search[index].DVD == "N/A" ? "Date Not Found" : item.Search[index].DVD}</span></span>
</div>
</div>
</div>
`
})
fiks = fiks.join(" ")
console.log(fiks);
this.topParents.style.display = "none"
this.mostPopulerHeader.style.display = "none"
if (film.Title == undefined) {
this.resultHeader.style.display = "block"
this.resultHeader.textContent = "NOT FOUND"
this.resultParent.innerHTML = `
<i class="fas fa-sad-cry" style="font-size:450px; color:navy;"></i>
`
} else {
this.resultHeader.style.display = "block"
this.resultHeader.textContent = "RESULTS"
// this.resultParent.innerHTML = fiks
}
}