My application includes a service that sends a POST request to a server:
addPerson(person:PersonDTO) :Observable<any> {
return this.httpClient.post<any>(this.urlBase + 'Persons', person);
}
When subscribing to the service in a component:
this.valueService.addPerson(person).subscribe((data) => {
this.responseCode = data.statusText;
console.log(this.responseCode)
});
I want to display the response code on the console. However, if there is an error, the code stops before reaching the console.log
. And if there is no error, undefined
appears on the console.