簡體   English   中英

JSON 解析錯誤:意外的標識符“be”

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

我彈出了我的 CRNA 應用程序,我編譯了它並在我的 android 設備上運行它。 然后我在嘗試在應用程序中搜索電影時遇到此錯誤,該應用程序由以下代碼管理。 有什么解決辦法嗎?

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));
}

嘗試這個:

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));
}

我遇到了同樣的問題,但最后

我找到它了

“api 已關閉”

你可以檢查你的api密鑰

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

api 掛了

我有完全相同的問題,我剛剛找到了解決方案。

問題是 TheMovieDB,如果您嘗試在瀏覽器中運行 url,您會看到“馬上回來”

但是在 URL 中,您只需要將“3”更改為“4”就可以了! (我無法解釋為什么,但它有效!)

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