简体   繁体   English

JSON 解析错误:意外的标识符“be”

[英]JSON Parse error: Unexpected identifier "be"

I ejected my CRNA app, I compiled it and run it on my android device.我弹出了我的 CRNA 应用程序,我编译了它并在我的 android 设备上运行它。 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" “api 已关闭”

you can check with your api key你可以检查你的api密钥

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

api is down api 挂了

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"问题是 TheMovieDB,如果您尝试在浏览器中运行 url,您会看到“马上回来”

But in the URL, you just need to change the "3" to a "4" and it work !但是在 URL 中,您只需要将“3”更改为“4”就可以了! (I can't explain why but it works !) (我无法解释为什么,但它有效!)

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

;) ;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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