Saturday, 1 August 2020

Help with connecting and querying PostgreSQL database using node-Postgres

Hi guys,So I am trying to query a postgres server on a google instance but I am having some issues with getting data back. I can hit the database and retrieve the fields of the table but no data, the array for rows is empty . I know there's data in that table too.const { Client } = require('pg'); const client = new Client({ user: '', password: '', host: '', port: '', database: '' }); client.connect(); client.query("SELECT * FROM reminders", (err, res) => { if (err) { console.error(err); console.log("dfd") return; } console.log(res) for (let row of res.rows) { console.log(res) console.log(row); } client.end(); }); If anyone has some ideas that would be great.

Submitted August 01, 2020 at 10:45AM by Cross112

No comments:

Post a Comment