Why is this not returning correctly? Can anyone help? It gets the correct value from the database (rows[0] is correct data), but I just cant figure out how to return it properly.
module.exports = {
get: function(query) {
var value = pool.getConnection(function(err, con) {
if (err) throw err;
con.query(query, function(err, rows) {
if (err) throw err;
con.release();
console.log(rows[0]); //Correctly prints
return rows;
})
})
console.log(value); //Prints undefined
return value[0]
}
}