最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

获取未定义错误的正文

IT培训 admin 4浏览 0评论

获取未定义错误的正文

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

payload={email:"[email protected]",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'

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

回答如下:

只是为了明确这里,问题是fetch的输入URL的值为undefined

这可能导致如下异常:

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

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

获取未定义错误的正文

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

payload={email:"[email protected]",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'

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

回答如下:

只是为了明确这里,问题是fetch的输入URL的值为undefined

这可能导致如下异常:

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

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

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论