-
-
Save phuoctamm/c0ca79fa74414fd5484fdcf3a5da0033 to your computer and use it in GitHub Desktop.
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
async function someFunction() { | |
const myArray = [1, 2, 3]; | |
const connection = mysql.createPool({ options }); | |
let finalArray = []; | |
myArray.forEach((value) => { // standard forEach | |
finalArray.push(asyncFunction(connection, value).then((result) => { | |
finalValue.asyncFunctionValue = result.asyncFunctionValue; // giving instructions | |
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