Skip to content
Advertisement

I’m really stumbed with this one. Not sure why My filter works in the console.log(filteredMovies) but not for displayMovies(filteredMovies)

Not sure what the problem is The code work fine until I try and use the filteredMovies in the displayMovies function not sure what is going on here. I am new to coding and am trying to get the api to work. Everything looks good until I get to this point. Not sure if there is another way to go about doing this or what I have to do to fix this but this has been very furstrating.

JavaScript

Advertisement

Answer

You’re filtering the ytxMovies.data.movies in the filteredMovies so the displayMovies will get ytxMovies.data.movies when you pass it so, it doesn’t have the data.movies when you map it!

Solution:

Change loadMovies to this:

JavaScript

This way it will pass an array to the displayMovies, then change the displayMovies to:

JavaScript

I changed your map a bit in displayMovies, the whole code:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement