I have developed an API in php which contains a Login method. When I run the API in postman with parameters such as email and password, the correct user is returned along with a JWT token that has been generated. However in my code in when I use a post method with the API the user seems to be returned but when I use navCtrl.navigateForward the page wont move from the login page to my dashboard.
auth-servie.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});
}
}
login.ts
login() {
this.authService.login(this.email, this.pw).subscribe(res => {
if (res) {
// store jwt
// move to dashboard
console.log('Valid User');
this.navCtrl.navigateForward('/menu/first');
}
}, error => {
if (error.status === 401) {
console.log('Authorisation Required');
}
}
);
}