【发布时间】:2019-10-12 00:50:30
【问题描述】:
我使用 axios post 来获取 react-native 中的数据,但响应未定义。有时它无法捕捉到错误,但它可能是由我的后端代码引起的。
我尝试了 http 和 https 但这不起作用,或者无论有没有标题都不起作用。有没有人发现我的代码错误?
axios
.post(
"http://192.168.1.34:3000/auth/",
{
email: email,
password: password
},
{
headers: { "Content-Type": "application/json" }
}
)
.then(response => {
console.log(response);
console.log(email);
})
.catch(error => {
console.log("loginAction:", error);
});
【问题讨论】:
-
你对后端有什么期望?
-
只想返回具有指定电子邮件和密码的用户令牌。邮递员完全可以工作。
标签: javascript react-native axios