React native 反应本机获取-请求正文-意外的EOF

React native 反应本机获取-请求正文-意外的EOF,react-native,fetch-api,React Native,Fetch Api,在我的react本机应用程序中,我试图使用body发出获取请求。但是,我收到了意外EOF的错误消息。实际上,请求是发出的,我的意思是我可以通过后端日志看到发送的请求,而在请求之后,它会显示错误消息 这是我的fetch方法 var Url = "https://----------"; return fetch(Url, { method: "POST", headers: { 'Accept': 'a

在我的react本机应用程序中,我试图使用
body
发出获取请求。但是,我收到了
意外EOF
的错误消息。实际上,请求是发出的,我的意思是我可以通过后端日志看到发送的请求,而在请求之后,它会显示错误消息

这是我的
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();
这是我得到的错误屏幕


我想说它在这一行失败:
response.json()
您确定您的响应是有效的JSON吗


尝试使用Postman测试响应,或者在
done()之前添加
.catch(e=>console.log(e))

我想说它在这一行失败:
response.json()
您确定您的响应是有效的JSON吗

尝试使用Postman测试响应,或者在
done()之前添加
.catch(e=>console.log(e))

您的服务器返回的是null而不是error,很遗憾,response.json()无法对null响应进行操作 你可以简单地研究一下,关键词是“处理来自api的空响应”

您的服务器返回的是null而不是error,很遗憾,response.json()无法对null响应进行操作 你可以简单地研究一下,关键词是“处理来自api的空响应”

var Url = "https://----------";
    return fetch(Url, {
        method: "POST",
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({'number': '11111111-'})
    })
        .then((response) => response.text())
        .then((responseJson) => {
             const resposeJson2 = responseJson.length ? JSON.parse(responseJson) : {};
            console.log("SEND_SMS RESULT: ",responseJson2);
        })
        .done();