我已经发布到我的API,并且一切正常(获取网络类等)。但是,在我调用该方法之后,其余代码将无法执行。
Login.ts
login() {
this.authService.login(this.email, this.pw).subscribe(result => {
if (result) {
console.log('Working');
this.presentLoading();
// store jwt
// move to dashboard
console.log('Valid User');
this.navCtrl.navigateForward('/menu/first/tabs/tab1');
this.router.navigate(['/menu/first']);
}
}, error => {
if (error.status === 401) {
console.log('Authorisation Required');
}
}
);
}
auth-service.ts
login(email, pw) {
if (email === '' || pw === '') {
this.presentAlert();
} else {
const params = new HttpParams()
.set('email', email)
.set('pw', pw);
return this.http.post<any>(apiUrl + 'login', {email, pw}, {params});
}
}
答案 0 :(得分:0)
尝试一下:
login(email, pw) {
return this.http.get(apiUrl + "login?"+"email="+email+"pw="+pw)
.map(res => res.json())
}
}
在 login.ts 中验证电子邮件和密码