Last active
December 24, 2022 22:05
-
-
Save feliperohdee/924dc23721bf5e858f52315881a64a6d to your computer and use it in GitHub Desktop.
promise.all-2.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const putData = async (data, ms) => { | |
return new Promise(resolve => { | |
setTimeout(() => { | |
resolve(data); | |
}, ms); | |
}); | |
}; | |
const [ | |
result1, | |
result2, | |
result3 | |
] = await Promise.all([ | |
putData({ | |
foo: 'bar-1' | |
}, 1000), | |
Promise.reject(new Error()), | |
putData({ | |
foo: 'bar-3' | |
}, 3000) | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment