简体   繁体   中英

JSON Parse error: Unexpected identifier "be"

I ejected my CRNA app, I compiled it and run it on my android device. Then I got this error while trying to do a search of a movie in the app which is managed by code below. Any solution?

const API_TOKEN = "********************************";
export function getFilmsFromApiWithSearchedText(text, page){
const url = 'https://api.themoviedb.org/3/search/movie?api_key=' + API_TOKEN 
 + '&language=fr&query=' + text + "&page=" + page
 return fetch(url)
   .then((response) => response.json())
   .catch((error) => console.error(error))

}

export function getImageFromApi(name){
return 'https://image.tmdb.org/t/p/w300' + name
}

export function getFilmDetailFromApi(id){
return fetch('https://api.themoviedb.org/3/movie/' + id + '?api_key=' + 
API_TOKEN + '&language=fr')
  .then((response) => response.json())
  .catch((error) => console.error(error));
}

Try this:

this.state = {
    ...
    responseDATA = '',  //You can also use an array
}

export function getFilmDetailFromApi(id){
    return fetch('https://api.themoviedb.org/3/movie/' + id + '?api_key=' + API_TOKEN + '&language=fr')
    .then((response) => response.json())
    .then((responseJson) => {
        this.state.responseDATA = responseJson.movie  //here movie is path of the data that you want from the JSON recieved
    })
    .catch((error) => console.error(error));
}

i faced the same problem, but in the end

i find it

"api is down"

you can check with your api key

https://api.themoviedb.org/3/search/movie?api_key=3d99a0336ddf835ade204ef86d5993dd&language=fr&query=me

api is down

I have exactly the same problem and I just found the solution.

The problem is TheMovieDB, if you try to just run the url in your browser you'll see "be right back"

But in the URL, you just need to change the "3" to a "4" and it work ! (I can't explain why but it works !)

https://api.themoviedb.org/ 4 /search/movie?api_key=xxxxxxxxxxxxxxxxx&language=fr&query=super

;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM