Film Finder Project

Ok, I’m losing it. I’ve gone through this project 4 times now, two of which I followed along step-by-step with the developer walk-through video and for some reason, this program is not working. I’m guessing it has something to do with my API key and/or the base URL for TMDB because my code doesn’t appear to have any errors so it seems like it’s just not connecting to the TMDB database every combination I try doesn’t change anything.
Does anyone have any advice on what steps I can take to sync them up? I pasted my code below but left my API Key blank for personal reasons.
I would love some advice/feedback on how the f to get this to work, thanks!

import { getSelectedGenre, getRandomMovie, displayMovie } from ‘./helper.js’;
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();
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();
const movies = jsonResponse.results;
return movies;
}
} catch(error) {
console.log(error);
}
};

const getMovieInfo = async (movie) => {
const movieId = movie.id;
const movieEndpoint = /movie/${movieId};
const requestParams = ?api_key=${tmdbKey};
const urlToFetch = ${tmdbBaseUrl}${movieEndpoint}${requestParams};

try {
const response = await fetch(urlToFetch);
if (response.ok){
const movieInfo = await response.json();
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 = await getMovieInfo(randomMovie);
displayMovie(info);
};

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

You have ./helper.js but some of the other people who have completed the project have ./helpers.js

Other versions of the project don’t have an import statement at all because that was handled by an earlier script element in the html, and the script elements don’t have type="module"

This was in the index.html file:

<script defer src="public/helpers.js"></script>
<script defer src="public/script.js"></script>

So the import may not be needed in your script.js file.

Remember to look at the browser’s console for errors and other output when the page is loading.