Home > OS >  Why do I have an error: "Invalid API key: You must be granted a valid key" when trying to
Why do I have an error: "Invalid API key: You must be granted a valid key" when trying to

Time:01-27

So I'm using Movies API from TMDB API, and my code looks like this:

let apikey = '{my_apikey}';
  let url: string = 'https://api.themoviedb.org/3/movie/apikey=';
  url = url   apikey;

  console.log(url);
  (async function () {
      const response = await fetch(url);
      const data = await response.json();
      console.log(data);
  })()

If I insert the url along with my API it displays the data just fine, but when I'm doing it from my app, I have the next error: enter image description here

I can't figure out what could be the problem, cause my api key is fine and I copied it from the website.

CodePudding user response:

According to the API documentation. The URL should look something like this:

https://api.themoviedb.org/3/movie/76341?api_key=<<api_key>>

  •  Tags:  
  • Related