💻 Tech
In an observable stream, use catchError
to intercept an error and handle it.
return this.api.get('/people').pipe(
catchError(error => {
console.error('Error occurred:', error);
// handle the error here (e.g., show error toast to the user)
return NONE; // complete an observable
// or `throw error`
})
);