Skip to content

Instantly share code, notes, and snippets.

@erikjung
Created April 18, 2018 01:50
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 erikjung/b4bc0d521f5c06f3684b863cc13bf128 to your computer and use it in GitHub Desktop.
Save erikjung/b4bc0d521f5c06f3684b863cc13bf128 to your computer and use it in GitHub Desktop.
Merging results of Promise.all
const a = new Promise(r => r({ a: 'A' }));
const b = new Promise(r => r({ b: 'B' }));
const c = new Promise(r => r({ c: 'C' }));
const result = (async () => {
const abc = await Promise.all([a, b, c]);
return abc.reduce((result, obj) => ({...result, ...obj}), {});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment