【发布时间】:2019-11-19 07:11:56
【问题描述】:
我在我的 expo react native 应用程序中使用 axios 发出发布请求,但我不知道为什么我的发布请求返回错误
请求失败,状态码 405
当我在邮递员上检查我的 API 时,它会向我显示预期的结果。我附加了在按钮上点击onPress 的方法。请检查并提供解决方案。
async onSubmit(ref) {
if (ref.state.emailID && ref.state.password) {
this.showLoader();
await axios.post('http://apiurl.com/api/user/Userlogin?emailID=' + ref.state.emailID + '&password=' + ref.state.password,
{ emailID: ref.state.emailID, password: ref.state.password },
{ headers: { 'Content-Type': 'application/json' } })
.then((response) => {
console.log('Innnn');
this.hideLoader();
console.log("response data: ", response.data);
}).catch(err => {
this.hideLoader();
console.log("error: ", err.message);
})
}
}
【问题讨论】:
-
为什么要在请求 URL 中附加 emailId 和密码?你能否附上你在邮递员中所做的事情以及你得到什么回应的截图(在你的问题中)?
标签: react-native axios react-native-android expo