여기 누군가가 나를 위해 문제를 해결할 수 있기를 바랍니다. 나는이 오류와 너무 오랫동안 싸우고있다. JSON 구문 분석 오류 :React 네이티브 가져 오기 오류 반환 : JSON 예기치 않은 EOF
는 나는이 같은 오류가 항상 발생하는 센서에 대한 API에 요청을 가져 제작하고 온라인 예기치 않은 EOF 내가 답을 찾기 위해 노력했다
과 시도 제안은 많았지 만 그 중 누구도 일하지 않았습니다.
개발 환경에서 로컬 네트워크를 통해 API에 액세스하고 있습니다.
은 API 인터페이스를 사용할 때 응답에서 얻는 JSON :
{
"device": null,
"patient": null
}
내가 얻는 JSON을
fetchUsers(timer) {
let data = {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json; charset=utf-8',
'Authorization': 'Bearer ' + this.state.token.access_token
}
}
fetch('http://' + this.state.ip + ':5000/api/Devices/031.01.0657/LiveState', data)
.then(response => response.json())
.then(responseJson => {
this.setState({
isLoading: false,
error: false,
userDataSource: responseJson,
refreshing: false,
time: timer
}, function() {
// If success, do something (I never make it to this part)
});
})
.catch(error => {
this.setState({
isLoading: false,
error: true
})
console.error(error);
});
}
나는 어떤 API 되돌아보고 다른 방법을 사용하고 물론이 응답시 우편 클라이언트를 사용할 때 :
{
"device": null,
"patient": null
}
정확한 sa 나 코드에서와 같이 URL. 반환 된 JSON은 유효한 JSON으로 전달됩니다.