Skip to content

Instantly share code, notes, and snippets.

@KMNowak
Created October 10, 2017 11:54
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 KMNowak/b692810ce3a4ce30228d1921d0cf0768 to your computer and use it in GitHub Desktop.
Save KMNowak/b692810ce3a4ce30228d1921d0cf0768 to your computer and use it in GitHub Desktop.
Resolving array of promises
const getProductImagesByIds = productImagesIds =>
Promise.all(productImagesIds.map(PROMISE_TO_SOLVE_WITH_ID_FROM_ARRAY))
.then(results => Array.isArray(results) ?
results.reduce((acc, row) => [...acc, row.url], []) :
[results]
)
.catch(e => {
throw new Error(e)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment