I have this typescript method in order to login user:
onSubmit() {
if (this.form.valid) {
this.authService.login(this.form.value).map(res => this.loginResponse = res.json).subscribe(
success => {
console.log('Response: ' + this.loginResponse);
},
error => {
this.loginFailed = true;
setTimeout(()=>{
this.loginFailed = false;
}, 3000);
console.error('ERROR login.component: ' + error);
}
);
}
this.formSubmitAttempt = true;
}
and actually I don't know how to get the response data inhere .map(res => this.loginResponse = res)
The output of console.log is:
Response: function () {
if (typeof this._body === 'string') {
return JSON.parse(/** @type {?} */ (this._body));
}
if (this._body instanceof ArrayBuffer) {
return JSON.parse(this.text());
}
return this._body;
}
Does anyone have any hint how I get the response object with observables.