Issue
How do I turn the below function in a async function?
getHandledSheet(): void {
this.timesheetService.getAllTimesheets().subscribe({next: (response: TimeSheet[]) => {this.timesheetsHandled = response.filter(sheet => sheet.status == 'HANDLED') }})
}
Solution
As in Matthieu's answer but fixing the syntax errors:
const timesheetObservable = this.timesheetService.getAllTimesheets();
const timesheets = await firstValueFrom(timesheetObservable);
this.timesheetsHandled = timesheets.filter(sheet => sheet.status == 'HANDLED');
Answered By - Robert Rendell
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.