【发布时间】:2021-02-28 09:22:16
【问题描述】:
我在网页端的 node js 中建立了一个网站,我设法使用 axios 登录到该网站。
export const logInFnc = async (email,password)=>{
try{
const login = await axios({
method:"POST",
url:"/api/v1/user/login",
data:{
email:email,
password:password
}
});
if(login.data.status = "success"){
showAlert('success','You have successfully logged in!!!');
window.setTimeout(()=>{
location.assign('/global-post')
},1500)
}
}catch(err){
showAlert('error',`There was a problem,you probably forgot your password or your email address is no longer valid.=>${err}`);
}
}
在浏览器中,它和在邮递员中一样正常工作, 但在 angular 中它给了我 400 的错误并且不识别任何东西
【问题讨论】:
-
但是 Angular 在浏览器中运行。它如何“在浏览器中”而不在 Angular 中工作?
-
另外,在 Angular 中,您使用 built-in HTTP client 发出 HTTP 请求,而不是使用 Axios 之类的第三方库。
标签: javascript node.js angularjs angular axios