I have a function in angular which return data set with status "Continue" or "finished". I want to keep hitting the call until status returns "finished" but for maximum one minute only. How can I achieve this in angular
public getLeadsResponse(key: any) {
this._service.getLeadsData(key).subscribe((response: any) => {
if (response) {
if (response.payload.status == "running") {
// here if i repeate this function it will start an infinite loop if status is always "running"
this.getLeadsResponse(key);
}
else if (response.payload.status == "finished") {
this.items = res.payload.result;
}
}
})
}