Error Handler Angular 6 HttpClient – catchError + retry – with SpringBoot RestAPIs example
In the tutorial, we show how to handle error from Angular HttpClient with catchError
& retry
when request fails on the SpringBoot server, or in case of a poor network connection.
Related posts:
@Injectable({
providedIn: 'root'
})
export class CustomerService {
private customersUrl = 'http://localhost:8080/api/customers'; // URL to web api
constructor(
private http: HttpClient
) { }
getCustomers (): Observable {
return this.http.get(this.customersUrl);
}
}
What happens if the request fails on the server, or if a poor network connection?
-> HttpClient
will return an error
object.
We can handle it from Component
code with .subcribe
:
More at:
Error Handler Angular 6 HttpClient – catchError + retry – with SpringBoot RestAPIs example
#angular #springboot #restapi #error-handler