The most of the httpClient interceptor tutorials are catching the errors response in order to show an alert.
Examples:
https://ionicacademy.com/ionic-http-interceptor/
https://medium.com/@deniscangemi/intercept-http-requests-in-angular-c6392b7b0e0
It possible to present a loader for each HTTP request using the interceptor?
If yes, How to handle or catch the successful HTTP request in order to dismiss the loader.
You can add a tap
function inside the pipe as well, which will execute for every run, like so:
import { tap, catchError } from 'rxjs/operators';
// ...
return next.handle(clonedReq).pipe(
tap(data => {
// Do your success stuff in here
}),
catchError(error => {
// Do your error handling in here
})
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With