获取未定义错误的正文
我很反应原生,我已经编写了登录代码
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
的第一个参数!
否则你会有一些神秘的错误导航。