I'm having a problem when I need to handle an error in an Angular service. In my scenario, a 404 return is not a mistake for me and I need to return Null to my front. My problem is that I still get the error in my console GET http://localhost:9000/api/funcionarios/user/3 404 (Not Found)
. Every time an error occurs in my application, a service of mine is triggered generating a log (which in this scenario should not occur)
component.ts
this.funcionario.findByUser(parseInt(account.id, 10)).subscribe((r) => {
this.setFuncionario(r.body);
}, (err) => {
this.setFuncionario(null);
});
service.ts
findByUser(id: number): Observable<EntityResponseType> {
return this.http
.get<Funcionario>(`${this.resourceUrlByUser}/${id}`, {
observe: 'response'
})
.map((res: EntityResponseType) => res);
}
The result is expected, but you are generating these error logs. Any idea?
Thanks