What Happens If the Request fails on the Server Due to Poor Network Connection?
HttpClient will return an error instead of a successful response.
Example - Add an error handler to handle the errors
How To Get and Log an error in Angular 4?
Two types of errors -
1. If the backend returns an unsuccessful response like - 404, 500 and so on
2. If something goes wrong in the client side like -network error etc.
In the both cases - We are using HttpErrorResponse and return the useful information on what went wrong in this call!
How To handle and retry the failed request due to Poor Network Connection in Angular 4?
In Angular 4, simply retry the request using RxJS operator called .retry (). It is automatically presubscribed to an Observable, thus reissuing the request when an error occurred!
Import RxJS for using retry () method-
HTTP Observables for retry the failed request
How to implement HttpCache in Angular 4?
We can use Http interceptors to implement caching.
References -I hope you are enjoying with this post! Please share with you friends. Thank you!!