获取未定义错误的正文

时间:2017-07-12 09:33:04

标签: node.js reactjs react-native

我很反应原生,我已经编写了登录代码

payload={email:"niju1992@gmail.com",password:"helo123"};
            var Options=
            {
              method: 'POST',
              headers: {'Accept': 'application/json','Content-Type': 'application/json'},
              body: payload 
            }

            fetch(Conf.API.SIGNIN, Options)
            .then((response) => 
              {
                if (response.status >= 400)
                {
                    throw new Error("Bad response from server");
                }
                return response.json();
              })
            .then((responseData) => 
            {
              //this.setState({data:responseData})
              console.log(responseData)  
            }) 
            .catch((error) => {
                  console.error("Error:"+error);
              })
            .done(); 

但我得到错误

  

index.android.bundle:19291错误:TypeError:无法读取属性   'bodyUsed'未定义

任何一位专家都可以。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:5)

在此明确说明,问题是fetch的输入网址的值为undefined

这可能会导致如此异常:

TypeError: Cannot read property 'bodyUsed' of undefined at new Request

确保fetch的第一个参数已定义!
否则你会有一些神秘的错误导航。