react-native提取-请求正文-意外的EOF [英] react-native fetch - request body - Unexpected EOF
问题描述
在我的本机应用程序中,我试图使用body
发出获取请求.但是,我收到unexpected EOF
的错误消息.实际上,请求已发出,我的意思是我可以通过后端日志看到请求已发送,而在请求之后,它立即显示错误消息.
in my react-native application, I'm trying to make fetch request with body
. But, I get error message of unexpected EOF
. Actually, the request is made, I mean I can see through backend logs that request is sent, whereas, right after the request, it shows error message.
这是我的fetch
方法.
var Url = "https://----------";
return fetch(Url, {
method: "POST",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({'number': '11111111-'})
})
.then((response) => response.json())
.then((responseJson) => {
console.log("SEND_SMS RESULT: ",responseJson);
})
.done();
这是我得到的错误屏幕.
here is the error screen I get.
推荐答案
我会说这行失败:response.json()
您确定您的回复是有效的JSON吗?
I would say that it fails on this line: response.json()
Are you sure that your response is a valid JSON?
尝试使用Postman测试响应,或者在done();
之前添加.catch(e => console.log(e))
Try testing the response with Postman or add .catch(e => console.log(e))
before done();
这篇关于react-native提取-请求正文-意外的EOF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!