const getDbInfo = (anArrayOfIDs) => {
return new Promise(function(resolve, reject){
let arrayOfDbInfoToSendBack = [];
for(let i = 0; i <= anArrayOfIDs.length-1; i++){
pool.query(
"SELECT * FROM `tbl_ofInfo` WHERE tbl_ofInfo.sqlID = '" +
anArrayOfIDs[i] +
"';",
async(err, res) => {
if (err) {
console.log("error: ", err);
} else {
for(let k = 0; k <= res.length-1; k++){
arrayOfDbInfoToSendBack.push(res);
}
resolve(arrayOfDbInfoToSendBack);
}
}
);
}
});
}
Expected this function to return an array of objects with information. I suspect I am using resolve incorrectly and it sending back an array of only 1 object when I want an array of multiple objects in it.