This post was flagged by the community and is temporarily hidden.
Don’t share your tmdbKey.
In getMovies
, you wrote:
if (response.ok){
const jsonResponse = await response.json();
console.log(jsonResponse);
const movies = jsonResponse.movies;
console.log(movies);
return movies;
}
Instead of
const movies = jsonResponse.movies;
it should be:
const movies = jsonResponse.results;
The TMDB API has response examples for different queries. You can click the “200 - Result” in the Response section to see example responses.
In getMovies
, you are using ... /discover/movie ...
for your url.
If you look at the example in the Response section of the documentation (https://developer.themoviedb.org/reference/discover-movie), you will see a sample response returns an object with the structure:
{
"page": ...,
"results": [ {...}, {...}, ... ],
"total_pages": ...,
"total_results": ...
}
therefore
const jsonResponse = await response.json();
const movies = jsonResponse.results;
return movies;
allows you to access the correct property.
Ah yes thank you, you are correct that does seem to be wrong.
However this doesn’t solve my issue completely. It is still saying that it cannot find ‘getSelectedGenre()’.
Also, in getMovieInfo
,
// You wrote:
const movieId = movie.movieId;
// It should be:
const movieId = movie.id;
Try making the above change. If that doesn’t work, then post the code in all your files (index.html
, helpers.js
and script.js
) along with your file directory structure (see this post for how someone else shared this info: Film Finder error - #10 by hiro36 )