hi!
I am stuck in the step no. 11 of the ‘Film Finder Project’. If you can please help.
const tmdbKey = ‘XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX’;
const tmdbBaseUrl = ‘https://api.themoviedb.org/3’;
const playBtn = document.getElementById(‘playBtn’);
Hi guys ,
I’m having this exact issue with some strange errors when I try to log ‘jsonResponse’
const tmdbKey = '********';
const tmdbBaseUrl = 'https://api.themoviedb.org/3';
const playBtn = document.getElementById('playBtn');
const getGenres = async () => {
const genreRequestEndpoint = '/genre/movie/list';
const requestParams = `?api_key = ${tmdbKey}`;
const urlToFetch = `${tmdbBaseUrl}${genreRequestEndpoint}${requestParams}`;
try{
const response = await fetch(urlToFetch);
if(response.ok){
const jsonResponse = await response.json();
console.log(jsonResponse)
}
}catch(error){
console.log(error)
}
};
const getMovies = () => {
const selectedGenre = getSelectedGenre();
};
const getMovieInfo = () => {
};
// Gets a list of movies and ultimately displays the info of a random movie from the list
const showRandomMovie = () => {
const movieInfo = document.getElementById('movieInfo');
if (movieInfo.childNodes.length > 0) {
clearCurrentMovie();
};
};
getGenres().then(populateGenreDropdown);
playBtn.onclick = showRandomMovie;
I can’t figure what is wrong with my codes, but I keep getting this particular Errors Messages
script.js:11
GET https://api.themoviedb.org/3/genre/movie/list?api_key%20=******* 401 (Unauthorized)
getGenres @ script.js:11
(anonymous) @ script.js:40
helpers.js:5 Uncaught (in promise) TypeError: genres is not iterable
at populateGenreDropdown (helpers.js:5:25)
I have followed what was done in the solution video, but my code isn’t showing any array still, instead I keep getting this errors repeatedly.
Not sure where I could have done any wrong