2017-10-13 91 views
0

在我的react-native应用程序中,我正在尝试使用body进行提取请求。但是,我收到了unexpected EOF的错误消息。实际上,请求已发出,我的意思是我可以通过后端日志查看发送的请求,而在请求之后,它会显示错误消息。react-native fetch - 请求正文 - 意外的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(); 

这里是我得到的错误屏幕。

enter image description here

回答

1

我要说的是,它没有在这条线:response.json() 你确定你的反应是一个有效的JSON?

尝试使用邮递员测试回复或在done();之前添加.catch(e => console.log(e))