I am using Promise.all to merge responses but if one promise fails it throws the error i have one promise returning successful call but one fails how can i fix this issue by resolving both promises ?
buildHeader function will take both responses whatever returns from both calls if its an error that should come back as well so i can have part of details
main.ts
private async execute(@Request() request: ExpressRequest): Promise < any > {
let _combineData: any =[];
try {
const _dataSpecialty = this.specialtyHandler.specialtyRequestHandler(request);
const combinedResponses = await Promise.all([
_dataSpecialty,
this.caremarkHandler.caremarkRequestHanlder(request)
]);
_combineData = this.buildHeader(combinedResponses, request.body);
} catch(err) {
return err;
}
return _combineData;
}
private buildHeader(combinedResponse: any[],
request: ICombinedAccountBalanceRequest): any {
return {
getAccountBalanceResponse: {
header: makeVordelSuccessHeader(request),
details: combinedResponse
}
};
}