Answer the question
In order to leave comments, you need to log in
Why doesn't the interceptor return the ErrorResponse to the handler?
I'm trying to write an interceptor that will prevent the script from exiting in case of an error from the server.
This is how I call the service method in the component:
const res = await this.service.getLandingPage(url);
// do actions with res
console.log(res)
async getLandingPage<T>(url: string): Promise<Page> {
return this.get<Page>(url,
{
observe: "response"
}
).toPromise();
}
return next.handle(request).pipe(
catchError((error: HttpErrorResponse) => {
this.log.error(error);
return EMPTY;
})
);
Answer the question
In order to leave comments, you need to log in
return throwError(error)
catchError requires an observable to be returned, and you give it a plain value
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question