I have a unique situation where 2 promises are running together in Promise.all. but one of the promise is taking long time and hence I am not getting any result. Other promise are getting resolved except one. I want to reject the promise taking long time (eg: if more than 60 sec) with an error message so that I can get a response from Promise.all.
e.g::
const [client1Prices, client2Prices] = await Promise.all([
this.client1.getSimulationPrices({
hourPay: journey.hourPay,
jobType: journey.jobType,
salary: journey.salary,
weeklyHours: journey.weeklyHours,
}),
this.client2.getSimulationPrices({ // takes more than 60 sec and i want to reject this promise
hourPay: journey.hourPay,
jobType: journey.jobType,
salary: journey.salary,
weeklyHours: journey.weeklyHours,
})
]);
this.client2.getSimulationPrices is taking a lot of time to resolve and hence Promise.all is not giving me any result. I want to reject this in 60 second such thatI can get response from Promise.all.
Please suggest how can this situation be handled ?