My Angular application includes a http POST call that takes approximately 15-20 seconds to complete. On the backend, I calculate a value for a progress bar related to this post call on the frontend.
Now, I am looking to execute http GET calls every 250ms once the POST call is initiated until it is finished.
I have explored the operators in Rxjs, but I am struggling to figure out how to properly combine/pipe them (e.g., timer or interval).
Below is my current code snippet:
// This Observable performs the POST call upon subscription
const x = this.apiService.importBackUp(this.backupList);
x.subscribe(); // Here, I aim to subscribe to my GET call every 250ms until completion
apiService.ts:
importBackUp(backup: BackupList[]): Observable<any> {
return this.httpClient.post(this.API_URL + '/Settings/import', backup)
.pipe(
catchError(this.handleError('Import Backup', null))
);
}
getProgress(): Observable<number> {
return this.httpClient.get<number>(this.API_URL + '/Settings/progress')
.pipe(
catchError(this.handleError('Get Import Progress', null))
);
}