I am using Nodejs, for the postgresql part I am using pg-promise. The query is performed with the following function, but I would like to save the data variable, which is the one with the values of the query, so I can use them later.
function getUnUsuario2(req, res, next) { var pupID = req.body.usuario; db.any('select * from tienda.usuarioadmin where nombre_usuario= $1', pupID) .then(function (data) { localStorage.Usuariosa=data; if(data[0]==null){ res.status(200) .json({ status: 'No existe D:' });}
else { res.redirect (' link '); }
}) .catch(function (err) { return next(err); });
}