Sunday 19 November 2017

Trying to get going with node-postgres

I am pretty new to javascript and node in general. Just completed a Udemy course and have just started develop my own app.I am just doing my first test, connecting to my postgres database. I am just trying to follow the documentation with a simple example. But this give me an error "TypeError: Client is not a constructor"Can someone please point out what I am misinterpret from the doc?This is the code it its essential // RequireClient = require('pg'); // Route using pgapp.get('/data', function (req, res) { const client = new Client({databaseConfig}); client.connect((err) => { if (err) { console.error('connection error', err.stack) } else { console.log('connected') } }) });

Submitted November 19, 2017 at 06:17PM by geoholic

No comments:

Post a Comment