Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var pool = new Pool({
- user: 'Rumen',
- password: 'pass',
- database: 'events',
- host: 'localhost', // force a fail in connection
- port: 2468,
- });
- app.get('/data', (req, res) => {
- pool.connect().then(client => {
- client.query("SELECT * FROM events")
- .then(data => {
- client.release();
- return res.json(data.rows);
- })
- .catch(e => {
- console.log('opa->',e);
- client.release();
- return res.status(500).json({success: false, data: e});
- })
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement