I am trying to connect to a PostgreSQL server that I created using Heroku through Node.js in a local instance. The issue I'm having is that the connection never gets established and I'm having trouble understanding why because there's no error output. The following is a snippet of my code:
async function main(){
const { Pool } = require('pg');
const pool = new Pool({
connectionString: "postgres://very_long_url_here" || process.env.DATABASE_URL,
ssl: {
rejectUnathorized: false
}
});
const client = await pool.connect();
console.log('connection established.');
const currentRecord = await client.query(`SELECT * FROM test_table WHERE email='[email protected]'`);
console.log(currentRecord);
console.log('records pulled');
}
main();
When I run this script through the command line, none of the console.log() commands get printed, but I also don't get any errors back, although the connection clearly doesn't happen. I got the connection string for the postgres database by running heroku pg:credentials:url DATABASE through the heroku CLI. Very new to node, heroku, and the stack community - I appreciate any feedback you might have!