2016-08-13 71 views
4

我是新來取回反應原生和跟隨this tutorial
我想發送一個json主體到一個私人api服務器,我檢查了服務器日誌,發現主體內容是空的。反應原生提取不發送正文內容

下面是代碼在本地反應

authenticateLogIn(){ 
    fetch('<URL>', { 
      method: 'POST', 
      header: {'Content-Type': 'application/json', 'Accept': 'application/json'}, 
      body: JSON.stringify({'username': '<username>', 'password':'<password>'}) 
     }) 
     .then((incoming) => incoming.json()) 
     .then((response) => { 
      console.log(response.header); 
      Alert.alert(JSON.stringify(response.body)); 
     }) 
     .done(); 

回答

7

也許是因爲它shoueld是頭小號? (與s)

+0

啊,就是這樣,一直以爲它只是一個頭不是沒有S – XPLOT1ON