I am pooling connections to my Postgres DB with pg-pool
. I am having trouble, however, sending the results of my queries to the frontend. I assumed that I could use res.send
as usual but it is not recognized (I also tried return
). Here is my function:
exports.featList = function (req, res) {
pool.connect(function(err, client, done) {
if (err) {
return console.error('error fetching client from pool', err);
}
client.query('SELECT * FROM book WHERE featured=true', function (err,res) {
var json = JSON.stringify(res.rows);
return json;
client.release();
});
});