Mam taki service:
return this.http
.post('http://localhost:61862/api/Account/Register', JSON.stringify(data), {headers: headers})
.toPromise()
.then((res) => { res.json() }, (error) => { console.log(error.json().Message) });
Wprowadzam błędne dane i wyświetla mi w konsoli: The request is invalid.
Natomiast gdy wywołuję ten serwis i chcę odebrać dane (czyt. wiadomość o błędzie):
this._userService.setUser(email, password).then(res => {
console.log(res); // undefined
}, (error) => {
console.log(error);// <-- ?
});
Zwraca res jako undefined i wchodzi do 1 bloku, a nie do 2. W czym jest problem?