I have the following code:
myFunction() {
this.store$
.select(selectFoo, this.fooId)
.pipe(
switchMap(foo =>
// THE FOLLOWING API CALL RESULTS IN A 404
this.apiService.someApiCall(foo)
.pipe(
catchError(error => {
alert("There was an error!");
return of(null);
})
)
)
)
.subscribe(() => {
alert("We are in the subscribe block, proceed assuming success");
});
}
When I set it up to cause an error in this.apiServce.someApiCall
, e.g. a 404, the error alert happens, but also the alert in the subscribe block.
I would want it to abort in case of error and not go in the subscribe block, where I would handle the "success" case.
What am I missing?
Thanks!