#Need help with pogresql
20 messages · Page 1 of 1 (latest)
ohh
🤦♂️🤦♂️
@open oriole
It's still the same
const { Client } = require("pg");
const dotenv = require("dotenv");
console.log(process.env.DATABASE_URL);
const client = new Client(process.env.DATABASE_URL);
(async () => {
await client.connect();
try {
const results = await client.query("SELECT NOW()");
console.log(results);
} catch (err) {
console.error("error executing query:", err);
} finally {
client.end();
}
})();
console.log(process.env.DATABASE_URL); -> undefined
how????
const dotenv = require("dotenv");
Change to
require('dotenv').config();
THANKYOUU!!!!
and do it on top of your file
I've been trying the since eternity
but that is shown as one of the first things in dotenv documentation
If not sure -> read docs 🙂
it's ok, simplest things are often missed