Given that promise1 and promise2 are correctly resolved with the below code:
export const getExistingPayments = async (payments: Payment[]) => {
const promise1 = await getPayment(payments[0].paymentId)
const promise2 = await getPayment(payments[1].paymentId)
const results = [promise1, promise2]
return results
}
Can anybody help explain why the below code would just hang, the promises are never resolved or rejected:
export const getExistingPayments = async (payments: Payment[]) => {
const promise1 = getPayment(payments[0].paymentId)
const promise2 = getPayment(payments[1].paymentId)
const results = await Promise.all([promise1, promise2])
return results
}
It might also be worth mentioning that when only one promise is passed to the Promise.all the promise is resolved as expected, the below code also works fine:
export const getExistingPayments = async (payments: Payment[]) => {
const promise1 = getPayment(payments[0].paymentId)
const results = await Promise.all([promise1)
return results
}