Reputation: 5742
I have an implementation of a service call which might throw an error, is it possible to rerun the service call if it errors out?
captureMultiScreen(elem: Alert, overwrite: boolean, success?: Function, failed?: Function) {
this.spinnerValue = true;
const captureModel: Capture = {
member_id: elem.member_id,
gateway: elem.gateway,
account: elem.account,
alert_id: elem.alert_id,
transaction_id: elem.transaction_id,
overwrite: overwrite
};
this.captureService.CaptureScreenService(captureModel).subscribe(result => {
this.capServiceResponse = result;
},
(error) => {
// Retry "CaptureScreenService" here
}
Is there a way to just run the service call again if it reached the error callback?
Upvotes: 0
Views: 1114
Reputation: 382
You can use the retry function. In your code it would be something like:
this.captureService.CaptureScreenService(captureModel)
.pipe(retry(3)).subscribe(...)
Upvotes: 5