Retry and Loading Indicators
Implement retries and global spinners.
Two cross-cutting concerns
Interceptors are perfect for two app-wide behaviors: automatically retrying failed requests, and tracking a global loading state while any request is in flight.
Retrying with retry
Pipe retry after next(req) to re-attempt transient failures.
import { retry } from 'rxjs';
export const retryInterceptor: HttpInterceptorFn = (req, next) =>
next(req).pipe(retry(2));All lessons in this course
- Functional Interceptors
- Adding Auth Headers
- Handling Errors Globally
- Retry and Loading Indicators