Skip to content

Instantly share code, notes, and snippets.

@feliperohdee
Last active December 24, 2022 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feliperohdee/924dc23721bf5e858f52315881a64a6d to your computer and use it in GitHub Desktop.
Save feliperohdee/924dc23721bf5e858f52315881a64a6d to your computer and use it in GitHub Desktop.
promise.all-2.js
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