Skip to content

Instantly share code, notes, and snippets.

View phuoctamm's full-sized avatar

Phuoc Tam phuoctamm

View GitHub Profile
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
}));
});