I am trying to learn how to use javascript to connect to a postgresql database but when I try to log a query to the console using query.on(...), I get a type error that says \"q
query.on
has been removed from node-pg 7.
See https://node-postgres.com/guides/upgrading for how to properly handle rows.
The usual way is to use promises or async/await (using promises in a clearer way):
await client.connect();
var res = await client.query("SELECT * FROM json_test");
res.rows.forEach(row=>{
console.log(row);
});
await client.end();