I need help finding my error in Film Finder project

Film Finder link

I reached the last step of the project, but when i hit the “Lets Play” button, the console displays an error. My first guess was that I forgot to close a curly bracket or that I typed a character where it didn’t belong. Maybe I’ve been staring at the screen too long, I just cant find my syntax error.

Here are screenshots of the console error and the snippet of code it references.


1 Like

in the getMovieInfo function,
I had
const movieId = movie.id;
instead of
const movieId = movie.Id;

1 Like

Unfortunately I get the same error with both movie.id and movie.ID.

maybe the problem isn’t in the code shown in the post above …
my code is nearly identical for that part, but it works fine.

my code
const getMovieInfo = async (movie) => {
  let movieId = movie.id;
  let movieEndpoint = "/movie/" + movieId;
  let requestParams = "?api_key=" + tmdbKey;
  let urlToFetch = tmdbBaseUrl + movieEndpoint + requestParams;
  try {
    let response = await fetch(urlToFetch);
    if (response.ok) {
      const movieInfo = await response.json();
      return movieInfo;
    }
    else {
      // throw new Error("Request failed!");
      console.log("request [for movie] failed!");
    }
  }
  catch (error) {
    console.log(error);
  }

};

Hi,
In your try block, I only had urlToFetch as a parameter (i.e. no {cache:…} )
There’s also a couple of lines in the if block without ; which may be giving you an issue.

Hi, so I replaced my code with yours, and now its working fine. That’s so weird. The problem was with the getMovieInfo for sure. I’ll go line by line to see where I went wrong but this is a big help thanks!

I wish these projects had a “Show Solution” option like the lessons do. But I guess this forced me to reach out to the community, which is a good thing.

Yep I added that after I first saw the error above. It didn’t solve the problem, nor create any other errors. I’ll delete it since its apparently doing nothing. The instructions never mentioned adding it so I guess whoever designed this project wasn’t trying to trick me.

Haha you were 100% right the first time! I forgot .id was case-sensitive. I don’t know why I was still getting the error after you first told me but that was indeed the problem. Thanks again, I was about to just skip it.