const fetchTrendingMovies = async () => {
try {
const res = await axios.get('https://api.themoviedb.org/3/trending/movie/day', {
params: {
language: 'en-US',
page: 1
},
headers: {
Authorization: `Bearer ${process.env.REACT_APP_API_TOKEN}`
}
});
setMovies(res.data.results);
} catch (error) {
console.error('Lỗi khi lấy phim thịnh hành: ', error);
}
};
Un film, une émission télévisée ou un artiste est introuvable ? Connectez-vous afin de créer une nouvelle fiche.
Vous souhaitez évaluer ou ajouter cet élément à une liste ?
Pas encore membre ?
Réponse de bin28
le 19 juillet 2024 à 02h51
AUTHORIZATION with display: Sorry, you cannot authenticate with that credentials
Réponse de Travis Bell
le 19 juillet 2024 à 11h24
Is
REACT_APP_API_TOKEN
your API key, or your access token? It needs to be your access token if you're using bearer authorization. Using your API key as a bearer token will not work.Keep in mind, if you re-generated your API key, you will need to grab a new access token.