Skip to content

Instantly share code, notes, and snippets.

@popovkos
Last active May 25, 2018 07:29
Show Gist options
  • Save popovkos/a1c78fc016c0219c42ff2b28a0e8c734 to your computer and use it in GitHub Desktop.
Save popovkos/a1c78fc016c0219c42ff2b28a0e8c734 to your computer and use it in GitHub Desktop.
async function someFunction() {
const myArray = [1, 2, 3];
const connection = mysql.createPool({ options });
let resolvedFinalArray = await Promise.all(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
}));
return functionThatUsesResolvedValues(resolvedFinalArray);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment