Here is the code I have:
async getBranchDetails() ----component method
{
let banks = this.bankDataService.getBanks();
let branchTypes = this.branchDataService.getBranchTypes();
forkJoin([banks,branchTypes]).subscribe(results => {
this.setFormBankData(results[0]);
this.setFormBranchTypeData(results[1]);
});
}
----service
async getBanks(): Promise<IBankResponse[]> {
return await this.httpClient.get<Result<IBankResponse[]>>(baseUrl + '/Bank/GetBanks')
.pipe(map( res => res.data)).toPromise();
}
Fork join is showing deprecated. Is there any alternative use with async
/await
. Thanks.
EDIT: i dont no whether it isright or not but used asyn/await..My final code as below
async getBranchDetails()
{
let banks = await this.bankDataService.getBanks();
let branchTypes= await this.branchDataService.getBranchTypes();
this.setFormBankData(banks);
this.setFormBranchTypeData(branchTypes);
}