Error using Fetch

When using fetch to request data from The Movie DB I got stuck on this google inspect panel console error.
I don’t know what to do because I passed the API KEY correctly.
If anyone can help I would be grateful :slight_smile:

exercise link below:

const tmdbKey = ‘###’;
const tmdbBaseUrl = ‘’;
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 , {cache: ‘no-cache’});
if (response.ok) {
const jsonResponse = await response.json();
} catch (Error) {

Hi there. It looks like the problem is here:

const requestParams = “?api_key=tmdbKey”;

You are not handling concatenation correctly. tmbdKey is the name of your variable and not its value.
The correct way would be:

const requestParams = "?api_key=" + tmdbKey;
const requestParams = `?api_key=${tmdbKey}`;

Thank you very much, I didn’t notice.

1 Like