Sprijin Bază de date filme (The Movie Database)

Hi there, I have an issue with my API Key. If I search a "top rated" with basicFetch(/trending/all/week?language=pt-BR&api_key${API_KEY}) but, receive "items: {status_code: 7, status_message: "Invalid API key: You must be granted a valid key.", success: false" someone can help me?

10 răspunsuri (pe pagină 1 din 1)

Jump to last post

same problem

@Kaimzr said:

Hi there, I have an issue with my API Key. If I search a "top rated" with basicFetch(/trending/all/week?language=pt-BR&api_key${API_KEY})

Assuming you aren't putting an = in your API_KEY var (which seems unlikely), you're missing the HTML delimiter:

/trending/all/week?language=pt-BR&api_key=${API_KEY}

Would be what you're looking for.

Travis, Thanks for your reply, however the persistent error. and yes, i have a const with my api_key.

What’s is the full request that isn’t working?

Follow my code;

const API_KEY = '77e9fa013xxxxxxxxxxxxxx';
const API_BASE = 'https://api.themoviedb.org/3';

const basicFetch = async (endpoint) => {
    const req = await fetch(`${API_BASE}${endpoint}`);
    const json = await req.json();
    return json;
}

export default {
getHomeList: async () => {
    return [
        {
        slug: 'originals',
        title: 'Originais do Netflix',
        items:await basicFetch(`/discover/tv?with_network=213&language=pt-BRapi_key=${API_KEY}`)

},
   {
        slug: 'trending',
        title: 'recomendados para Você',
        items: await basicFetch(`/trending/all/week?language=pt-BR&api_key=${API_KEY}`)
   },
   {
    slug: 'toprated',
    title: 'em alta',
    items: await basicFetch(`/movie/top_rated?language=pt-BR&api_key=${API_KEY}`)
   }, 
   {
    slug: 'action',
    title: 'Ação',
    items: await basicFetch(`/discover/movi?with_genres=28&language=pt-BR&api_key=${API_KEY}`)
   }, 
   {
    slug: 'comedy',
    title: 'comedia',
    items: await basicFetch (`/discover/movi?with_genres=35&language=pt-BR&api_key=${API_KEY}`)
   }, 
   {
    slug: 'horror',
    title: 'terror',
    items: await basicFetch (`/discover/movi?with_genres=27&language=pt-BR&api_key=${API_KEY}`)
   }, 
   {
    slug: 'romance',
    title: 'romance',
    items: await basicFetch (`/discover/movi?with_genres=10749&language=pt-BR&api_key=${API_KEY}`)
   }, 
   {
    slug: 'documentary',
    title: 'documentarios',
    items: await basicFetch (`/discover/movi?with_genres=99&language=pt-BR&api_key=${API_KEY}`)
   }, 
];
}
}

all requests return me, error 401 and 404, and say my api key is invalid.

@Kaimzr said:

Follow my code;

all requests return me, error 401 and 404, and say my api key is invalid.

I believe there are some characters missing from your Requests.
Always put your API Key after the " ? "
Try building your API Request with this other sequence:

title: 'Originais do Netflix',
https://api.themoviedb.org/3/discover/tv?with_network=213&language=pt-BRapi_key=${API_KEY}`)
https://api.themoviedb.org/3/discover/tv?api_key=THE_KEY&language=pt-BR&with_networks=213
You forgot the & character before with_network=

title: 'recomendados para Você',
https://api.themoviedb.org/3/trending/all/week?language=pt-BR&api_key=${API_KEY}`)
https://api.themoviedb.org/3/trending/all/week?api_key=THE_KEY
In trending it is not possible to specify the language (pt-BR).

title: 'em alta',
https://api.themoviedb.org/3/movie/top_rated?language=pt-BR&api_key=${API_KEY}`)
https://api.themoviedb.org/3/movie/top_rated?api_key=THE_KEY&language=pt-BR
You forgot the & character before language=

title: 'terror',
https://api.themoviedb.org/3/discover/movi?with_genres=27&language=pt-BR&api_key=${API_KEY}`)
https://api.themoviedb.org/3/discover/movie?api_key=THE_KEY&language=pt-BR&with_genres=27
In this case you wrote movi, that is, movie without the " e " character at the end.

There are probably some other minor errors. :-)

@ticao2 said:

@Kaimzr said:

Follow my code;

all requests return me, error 401 and 404, and say my api key is invalid.

I believe there are some characters missing from your Requests.
Always put your API Key after the " ? "
Try building your API Request with this other sequence:

title: 'Originais do Netflix',
https://api.themoviedb.org/3/discover/tv?with_network=213&language=pt-BRapi_key=${API_KEY}`)
https://api.themoviedb.org/3/discover/tv?api_key=THE_KEY&language=pt-BR&with_networks=213
You forgot the & character before with_network=

title: 'recomendados para Você',
https://api.themoviedb.org/3/trending/all/week?language=pt-BR&api_key=${API_KEY}`)
https://api.themoviedb.org/3/trending/all/week?api_key=THE_KEY
In trending it is not possible to specify the language (pt-BR).

title: 'em alta',
https://api.themoviedb.org/3/movie/top_rated?language=pt-BR&api_key=${API_KEY}`)
https://api.themoviedb.org/3/movie/top_rated?api_key=THE_KEY&language=pt-BR
You forgot the & character before language=

title: 'terror',
https://api.themoviedb.org/3/discover/movi?with_genres=27&language=pt-BR&api_key=${API_KEY}`)
https://api.themoviedb.org/3/discover/movie?api_key=THE_KEY&language=pt-BR&with_genres=27
In this case you wrote movi, that is, movie without the " e " character at the end.

There are probably some other minor errors. :-)

tnx man

@Kaimzr said:

A curiosity of mine, I speak pt-BR.
You are the 4 user who speaks pt-BR that comes here in the last 10 days with the same problem.
Are you taking any code programming course that uses API?
Is it a school or online?
Can you say the name of the course, where it is, etc...?

@bukqueiroz said:

tnx man

A curiosity of mine, I speak pt-BR.
You are the 4 user who speaks pt-BR that comes here in the last 10 days with the same problem.
Are you taking any code programming course that uses API?
Is it a school or online?
Can you say the name of the course, where it is, etc...?

Nu găsiți un film sau un serial? Autentificați-vă pentru a-l crea.

Global

s focalizați bara de căutare
p deschideți meniul profilului
esc închide o fereastră deschisă
? deschideți fereastra de scurtături de la tastatură

Pe paginile media

b înapoi (sau la pornire atunci când este cazul)
e accesați pagina de editare

Pe paginile sezonului TV

(săgeată dreapta) mergeți la sezonul următor
(săgeată stânga) mergeți la sezonul precedent

Pe paginile episoadelor TV

(săgeată dreapta) mergeți la următorul episod
(săgeată stânga) mergeți la episodul anterior

Pe toate paginile de imagini

a deschideți fereastra pentru adăugarea imaginii

Pe toate paginile de editare

t deschide selectorul de traduceri
ctrl+ s trimiteți formularul

Pe paginile de discuții

n creați o nouă discuție
w comutați stare de vizionare
p comutați public/privat
c comutați închidere/deschidere
a deschide activitatea
r răspuns la discuție
l mergeți la ultimul răspuns
ctrl+ enter trimiteți mesajul
(săgeată dreapta) pagina următoare
(săgeată stânga) pagina anterioară

Setări

Doriți să evaluați sau să adăugați acest element într-o listă?

Autentificare