since i've upgraded to Angular 5 and started using httpclient. I am unable to get just a simple login function to work. Can someone help me out?
auth service:
login(email: string, password: string): Observable<boolean> {
return this.http.post(environment.api_url + '/authenticate', {email: email, password: password})
.map(response => {
if (response && response.token) {
localStorage.setItem('token', response.token);
return true;
} else {
return false;
}
}
)
.catch(err => Observable.of(false));
}
and the login page controller:
login() {
this.loading = true;
this.auth.login(this.credentials.email, this.credentials.password)
.subscribe(
data => {
if (data) {
this.router.navigate([this.returnUrl]);
}
},
data => {
this.loading = false;
if (data.error && data.error.message) {
this.loginError = data.error.message;
}
});
}
This gives me error(s):
ERROR in src/app/services/auth.service.ts(104,36): error TS2339: Property 'token' does not exist on type 'Object'. src/app/services/auth.service.ts(105,52): error TS2339: Property 'token' does not exist on type 'Object'.