var names = [];
db.query(`SELECT * FROM department`, (err, rows) => {
if (err) {
console.log(err);
return;
}
names = rows.map(x => x.name);
})
console.log(names);
Hi guys, been messing with this code all day but can't for the life of me figure out why my variable "names" will always print an empty array, rather than be populated with what occurs during this query. I defined it outside of the query scope, so shouldn't that mean that the value I populate it with inside the scope should persist afterwards?