module.exports.getTragos = function(req, res) {
var connection = conectar();
connection.connect();
connection.query('SELECT * from tipoAlcohol', function(err, rows, fields) {
if (!err)
return JSON.stringify(rows));
else
return 'Error while performing Query.';
});
connection.end();
}
I would like to make the getTragos function to return the rows of the query executed, but return JSON.stringify(rows)); is not returning them. I tried to put console.log(rows) and the query is executed fine.
This is the code that invokes getTragos:
module.exports.iniciar = function(app) {
app.get('/bebidas/getTipoAlcohol', function (req, res) {
res.send(modelo.getTragos());
});
}