Created
October 10, 2017 11:54
-
-
Save KMNowak/b692810ce3a4ce30228d1921d0cf0768 to your computer and use it in GitHub Desktop.
Resolving array of promises
This file contains 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 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