내 API로 전화를 걸려면 React Native에서 fetch를 사용하지만, 시간의 75 % 만 작동합니다.반응 네이티브로 가져 오기
TypeError: Network request failed
또는
SyntaxError: Unexpected token < in JSON at position 0
fetch('http://localhost/vision.php', {
method: 'POST',
headers: {
'Accept': 'application.json',
'Content-Type': 'application.json',
},
body: JSON.stringify({
key: 'Mon paramètre'
})
})
.then((data) => data.json())
.then((dataJson) => {
console.log(dataJson.message);
})
.catch((error) => {
console.log(error);
});
}
누군가가 그것을 설명 할 수있다 : 내 요청이 작동하지 않는 경우 나는이 얻을?
이 줄 다음에 "if (dataJson! == null) {..."을 입력하면 ".then ((dataJson) => {"이어도 그대로 유지됩니다) –