Sprijin Bază de date filme (The Movie Database)

Hey, I was granted an API key, but when I implemented it into my code, I keep getting {"status_code":7,"status_message":"Invalid API key: You must be granted a valid key.","success":false}. here is my code: import React, { useState, useEffect } from "react"; import "./OptionsTabs.css"; import Nav from 'react-bootstrap/Nav'; import NavDropdown from 'react-bootstrap/NavDropdown'; import GenreList from "./GenreList";

function OptionsTab () { const { VITE_MOVIE_API_KEY } = import.meta.env

const [genres, setGenres] = useState([]);


const fetchGenresData = async () => {
    try {
        const response = await fetch(
          `https://api.themoviedb.org/3/genre/movie/list?language=en&${VITE_MOVIE_API_KEY}`,
          {
            headers: {
                accept: 'application/json',
                Authorization: `Bearer ${VITE_MOVIE_API_KEY}`,
            },

          }  
        );

        if (!response.ok) {
            throw new Error(`Error fetching genres: ${response.statusText}`);
        }
        const data = await response.json();
        setGenres(data.results);
    }   catch (error) {
        console.error('Error fetching genres:', error);
    }
};

useEffect(() => {
    fetchGenresData();
}, []);  

Can anyone help me out? Although I'm pretty sure its not my code and its the API key itself

1 răspuns (pe pagină 1 din 1)

Jump to last post

@MeaganHworth said:
Invalid API KEY
Hey, I was granted an API key, but when I implemented it into my code, I keep getting
{"status_code":7,"status_message":"Invalid API key: You must be granted a valid key.","success":false}.
here is my code: import React, { useState, useEffect } from "react";
import "./OptionsTabs.css";
...
fetchGenresData();
}, []);
Can anyone help me out?
Although I'm pretty sure its not my code and its the API key itself

Only the Travis Bell admin and you can access your API Key.
So I suggest you

Take a Test
Using a computer, desktop or notebook.
On some mobile devices this test may not work correctly.
In the URL below, change THE_KEY to your API Key.
https://api.themoviedb.org/3/movie/550?api_key=THE_KEY
Use this example to do a search using a new tab or window in your browser.
You will receive the basic data of the Movie Fight Club (1999)
https://www.themoviedb.org/movie/550-fight-club
If it works, your Key is OK.

When there is a problem, the TMDb Server sends a message.
Can you tell which message the server sent?
Here is a list of possible messages:
https://developer.themoviedb.org/docs/errors

If it does not work, let us know right here.

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