react-native fetch - request body - Unexpected EOF

前端 未结 2 398
醉话见心
醉话见心 2021-01-27 07:22

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,

2条回答
  •  遥遥无期
    2021-01-27 07:55

    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();
    

    Your server is returning null instead of error and unfortunately response.json() cant operate on null response you can research briefly on it the keywords are "Handling null response from api"

提交回复
热议问题