When I try the api out in the browser using my api key, I receive the correct data. However, when I fetch that link in my code, I receive that error. I am running my code in NextJs13 and Typescript.
Can't find a movie or TV show? Login to create it.
Want to rate or add this item to a list?
Not a member?
Reply by robbie3999
on July 20, 2023 at 6:11 PM
Hi @tacolegs2004, hard to tell without seeing more information, but it looks like whatever variable you are using for the api_key is undefined when you use it.
If you are reading the key from an env file, then see these discussions about what can go wrong:
https://stackoverflow.com/questions/49579028/adding-an-env-file-to-a-react-project
https://stackoverflow.com/questions/48378337/create-react-app-not-picking-up-env-files
Reply by ticao2 š§š· pt-BR
on July 21, 2023 at 8:01 AM
It would help to know which of the 401 error responses you are getting.
See the list of TMDb server error warnings here.
https://www.themoviedb.org/documentation/api/status-codes
In your case: