Film finder Practical

Hi there. I’ve just completed the film finder project and I’ve encountered two errors:
‘no eval config to sync…console.Observable.js:30’ and ‘no eval config to sync… sagas.ts:164’
I’ve combed through the code and don’t pick up anything. Please help.

const tmdbKey = ‘7d9c92ee488f86e21f9a5dd2d2473619’;
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();
const genres = jsonResponse.genres;
return genres;
}
} catch (error) {
console.log(error);
}
};

const getMovies = async () => {
const selectedGenre = getSelectedGenre();
const discoverMovieEndpoint = ‘/discover/movie’;
const requestParams = ?api_key=${tmdbKey}&with_genres=${selectedGenre};
const urlToFetch = ${tmdbBaseUrl}${discoverMovieEndpoint}${requestParams};
try {
const response = await fetch(urlToFetch);
if(response.ok) {
const jsonResponse = await response.json();

}

} catch (error) {
console.log(error);
}

};
getMovies();
const getMovieInfo = async (movie) => {
const movieId = movie.id;
const movieEndpoint = /movie/${movie.id};
const requestParams = ?api_key=${tmdbKey};
const urlToFetch = ${tmdbBaseUrl}${movieEndpoint}${requestParams};
try {
const response = await fetch(urlToFetch);
if (reesponse.ok) {
const jsonResponse = await response.json();
const movieInfo = jsonResponse;
return movieInfo;
}
} catch (error) {
console.log(error);
}
};

// Gets a list of movies and ultimately displays the info of a random movie from the list
const showRandomMovie = async () => {
const movieInfo = document.getElementById(‘movieInfo’);
if (movieInfo.childNodes.length > 0) {
clearCurrentMovie();
};
const movies = await getMovies();
const randomMovie = getRandomMovie(movies);
const info = getMovieInfo(randomMovie);
displayMovie(info);
};

getGenres().then(populateGenreDropdown);
playBtn.onclick = showRandomMovie;

It is difficult to read code if its formatting has been lost.
To preserve code formatting in forum posts, see: [How to] Format code in posts

  • Don’t share your tmdbKey.

  • In the try block of getMovies, you don’t seem to be returning anything. Aren’t you supposed to return jsonResponse.results? Did it get lost while copy-pasting your code or you forgot to write the code?

  • What is the purpose of the getMovies(); statement? (the statement just before the definition of getMovieInfo)

  • In the try block of getMovieInfo, you wrote    if (reesponse.ok) {

  • In showRandomMovie, you wrote: const info = getMovieInfo(randomMovie);.
    Try changing it to: const info = await getMovieInfo(randomMovie);

Thank you so much. I’ll give this a try.

1 Like

Btw how do I edit or delete a post?

I think if too much (I don’t know how long) time has passed, then the option to edit posts is disabled. However, you can still delete posts. Just click on the three dots below the post (the “show more” dots) and it should offer you options to delete or bookmark or flag posts. If too much time hasn’t elapsed, then the option to edit will also be there in the shape of a pencil icon.

Also, Codecademy has been tinkering with the forums, so the link I posted earlier doesn’t work. Another link that is working is: How do I format code in my posts?