By passing an ID for 60 seconds as payload in an API for getting the status of a transaction. API will give statuses Progress , Completed and Failed. If response is "Progress" it has to run the timer until "Success" / "Failure" and need to exit the timer.
1. The issues right now are even if API gives "Success" / "Failure" it will not exit the timer it keep on loading for one minute.
2. If API get failed it will be in a never ending loop.
I tried adding routing after the response is "Success" / "Failure" for that also it is waiting for 60 S.
intervalVal=interval(50000)
checkstatus(id) {
this.timeInterval = this.intervalVal.subscribe(() => {
this.transactionstat(id).subscribe((statres: any) => {
switch (statres.status) {
case "progress":
this.stepper.selectedIndex = 0;
case "Sucess":
this.steppershow = false;
this.stepper.selectedIndex = 1;
this.stepper.selectedIndex = 2;
this.timeInterval.unsubscribe()
setTimeout(() => {
this.router.navigateByUrl("/home");
}, 3000);
break;
case "Failed":
this.stepper.selectedIndex = 1;
this.stepper.selectedIndex = 3;
this.timeInterval.unsubscribe()
setTimeout(() => {
this.router.navigateByUrl("/home");
}, 3000);
break;
}
})
});
}
My requirement is to exit the timer after the desired response not to wait for the entire one minute and exit timer after one minute. Help with your valuable suggestions.