Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var pool = new Pool({
  2.     user: 'Rumen',
  3.     password: 'pass',
  4.     database: 'events',  
  5.     host: 'localhost', // force a fail in connection
  6.     port: 2468,
  7. });
  8. app.get('/data', (req, res) => {
  9.     pool.connect().then(client => {
  10.         client.query("SELECT * FROM events")
  11.         .then(data => {
  12.             client.release();
  13.             return res.json(data.rows);
  14.         })
  15.         .catch(e => {
  16.             console.log('opa->',e);
  17.             client.release();
  18.             return res.status(500).json({success: false, data: e});
  19.         })
  20.     });
  21. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement