0
我剛剛從反應原生API獲取數據。代碼就像這樣。反應原生json響應無法解析
fetch(Config.SERVER_URL + '/api/login/tokencheck/' + accessToken, {
method: "GET",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
})
.then((response) => response.text())
.then((responseJson) => {
alert(responseJson);
alert(JSON.stringify(responseJson));
})
.catch((error) => {
alert("error");
alert(error);
console.log(error);
})
的問題是,在在回調的第一個警報,它告訴我,有一個像這樣{"name": "Abigail","state": "CA"}
JSON格式的字符串,但是,當我轉換是respon使用JSON.parse
JSON它返回錯誤意外的標記「 ? 。但是當我主動反應原生Remote Debuger時,它工作得很好。任何解決方案
您可以使用您的數據是這樣的。 ** ** this.state.data –