The Movie Database qoldaýy

I created a new api key and it's still not reading on my react project. Here is the code, any help would be appreciated. I have a .env file where the token and key are. Am i missing something?

const Add = () => { const [query, setQuery] = useState(""); const onChange = e => { e.preventDefault();

setQuery(e.target.value);

const options = {
  method: 'GET',
  headers: {
    accept: 'application/json',
    Authorization: `Bearer ${process.env.REACT_APP_ACCESS_TOKEN}`

  },
};


fetch(`https://api.themoviedb.org/3/search/tv?api_key=${process.env.REACT_APP_TMDB_KEY}&language=en-US&page=1&include_adult=false&query=${e.target.value}`
).then (res => res.json())
.then(data => {
  console.log(data)
})

};??

4 jaýap (1 ishinen 1 betinde)

Jump to last post

I updated the fetch to call the options in it and still nothing.

hi @derek12345, you should print (console.log()) the string you are trying to fetch to see if there is anything wrong with it. If the api_key is missing, then read this:

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

Remove the env file and add key to code it works and I am also getting same error when using env file

Hi @Mohit1310,

Remove the env file and add key to code it works and I am also getting same error when using env file

If this is the case then you need to review the two stackoverflow links above that discuss issues with reading from an env file.

Fılmdi nemese kórsetimdi taba almadyńyz ba? Ony jasaý úshin kirińiz.

Ǵalamdyq

s kezelimdi izdeý jolaǵyna aýystyrý
p profaıl mázirin ashý
esc ashyq terezeni jabý
? perneler tirkesimi terezesin ashý

Tasyǵyshtar betterinde

b artqa oralý (nemese qoldanylatyn bolsa, tektikke)
e óńdeý betine ótý

Telemaýsym betterinde

(oń jaq kórsetki) kelesi telemaýsymǵa ótý
(sol jaq kórsetki) aldyńǵy telemaýsymǵa ótý

Epizod betterinde

(oń jaq kórsetki) kelesi epızodqa ótý
(sol jaq kórsetki) aldyńǵy epızodqa ótý

Barlyq keskin betterinde

a keskin ústeý terezesin ashý

Barlyq óńdeý betterinde

t tárjime tańdaǵyshyn ashý
ctrl+ s pishindi jiberý

Talqylaý betterinde

n jańa talqylaýdy jasaý
w qaralǵan kúıin aýystyrý
p jalpy/jekeni aýystyrý
c jabý/ashýdy aýystyrý
a áreketterdi ashý
r talqylaýǵa jaýap berý
l sońǵy jaýapqa ótý
ctrl+ enter habaryńyzdy jiberý
(oń jaq kórsetki) kelesi betke
(sol jaq kórsetki) aldyńǵy betke

Parametrler

Want to rate or add this item to a list?

Kirý