Hi guys im new to nodejs and web development in general, can anyone smarter then me please explain why my 'vResult = vResult.push(rows[e].label);' is not working as intented?
When i console the array after the block i get an empty array? Whilst rows[e].label has a value in the for loop itself.
Am i overlooking something?
const proc = require('../config/db_config');
function findMatch(vLabel){
vToFind = vLabel;
vResult = new Array();
proc.vPool.getConnection()
.then(conn => {
conn.query(`SELECT * FROM ${process.env.DB_N}.Panels WHERE label = '${vToFind}';`)
.then(rows => {
for (var e = 0; e < rows.length; e++){
console.log(rows[e].url)
vResult = vResult.push(rows[e].label);
}
})
.catch(err => {console.log(err), conn.end})
})
.catch(err => {console.log(err), conn.end})
return vResult;
}
module.exports = {findMatch};```