【发布时间】:2022-01-20 21:19:17
【问题描述】:
这是我的 api 调用
api
.post("/auth/registration/", data)
.then((res) => {
console.log(res);
localStorage.removeItem("access");
localStorage.removeItem("refresh");
alert("Registration Successfull");
})
.catch((error) => {
console.log(Response.password1);
alert(error.message);
console.log(msg);
localStorage.removeItem("access");
localStorage.removeItem("refresh");
});
我想在响应部分提醒消息来自后端,我该怎么做
【问题讨论】:
-
你试过什么?
res.email?.[0]?还是您向我们展示的错误?请为您正在尝试做的事情分享一个更完整和全面的代码示例。 stackoverflow.com/help/minimal-reproducible-example -
当您记录“res”时,您可以显示控制台中显示的对象。还可以尝试记录应该为您提供响应数据的“res.data”