trying to gather some titles from my roles table and put them into an array so i can loop over them later but when i run the function it doesn't give me a array with the values I'm guessing
function setRoles() {
let roleSet = [];
let sql = "SELECT * FROM role";
connection.query(sql, function(err, res) {
if (err) throw err;
for (let i = 0; i < res.length; i++) {
roleSet.push(res[i]);
}
});
console.log(roleSet);
return roleSet;
}
here is the code the only thing i get back is a empty array and ive tried putting the array init outside the function and that doesnt work either