Last active
May 25, 2018 07:29
-
-
Save popovkos/8f09aa0fa293babb3ec86518a7502851 to your computer and use it in GitHub Desktop.
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
async function someFunction() { | |
const myArray = [1, 2, 3]; | |
const connection = mysql.createPool({ options }); | |
let finalArray = myArray.map(async(value) => { // map instead of forEach | |
const result = await asyncFunction(connection, value); | |
finalValue.asyncFunctionValue = result.asyncFunctionValue; | |
return finalValue; // important to return the value | |
}); | |
const resolvedFinalArray = await Promise.all(finalArray); // resolving all promises | |
return functionThatUsesResolvedValues(resolvedFinalArray); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment