Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Avoid async/await on integration level
const defaultFirst = 'A`'
const defaultSecond = 'B`'
const defaultThird = 'C`'
async function doFirst() {
// throw new Error('Error A')
return await 'A'
}
async function doSecond() {
//throw new Error('Error B')
return await 'B'
}
function doThirdSync() {
//throw new Error('Error C')
return 'C'
}
async function doThird() {
//throw new Error('Error C')
return new Promise(resolve => resolve(doThirdSync()))
}
(async () => {
const result = await Promise.all([
doFirst().catch(() => defaultFirst),
doSecond().catch(() => defaultSecond),
doThird().catch(() => defaultThird),
])
console.log(result)
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.