2017-10-13 94 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))