How to handle RxJs timeout complete - Angular HttpClient
This works
import { throwError, TimeoutError } from 'rxjs';catchError((error) => { // Error... // Handle 'timeout over' error if (error instanceof TimeoutError) { return throwError('Timeout Exception'); } // Return other errors return throwError(error);})
I implemented this at my intecerptor that has other functionalities, the code here
You can use timeoutWith operator to achieve this.
return this.http.post('http://localhost:3000/api/core', data).pipe( timeoutWith(3000, observableThrowError(new Error('Http Timeout exceeds'))), map((response: any) => { // Success... return response; }), catchError((error: HttpErrorResponse) => this.handleError(error)) );