From a8ce19e8c3791e115f0579e793213c1b37a87a0f Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Mon, 18 May 2015 16:29:44 +0200 Subject: [PATCH] Corrected bug --- server.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/server.js b/server.js index 5c6da5f..597f600 100644 --- a/server.js +++ b/server.js @@ -10,7 +10,6 @@ var app = express(); var bodyParser = require('body-parser') var urls = require('./urls'); - app.set('view engine', 'jade'); app.use(bodyParser.text()); @@ -33,10 +32,14 @@ app.post('/post', function(req, res) { var user_id = req.body.user_id; var arrow_id = req.body.arrow_id; - pg.connect(pgc.url, function(err, client, done) { - client.query("INSERT INTO arrowclicked(user_id, arrow_id) VALUES($1,$2);", [user_id, arrow_id], function(err, result) { - // console.log(err); - }); + pg.connect(pgc.url, function(err, client, release) { + client.query( + "INSERT INTO arrowclicked(user_id, arrow_id) VALUES($1,$2);", + [user_id, arrow_id], + function(err, result) { + release(); + } + ); }); res.setHeader('Content-Type', 'text/html');