When I try to run then function on it, it will return this error
TypeError: Cannot read properties of undefined (reading 'then')
at Object.\<anonymous\> (/app/src/index.js:52:2)
at Module.\_compile (node:internal/modules/cjs/loader:1546:14)
at Module.\_extensions..js (node:internal/modules/cjs/loader:1691:10)
at Module.load (node:internal/modules/cjs/loader:1317:32)
at Module.\_load (node:internal/modules/cjs/loader:1127:12)
^
const { Client } = require('pg');
const PG_USER = 'root';
const PG_PASSWORD = 'example';
const PG_HOST = 'postgres';
const PG_PORT = '5432';
const PG_URI = `postgresql://${PG_USER}:${PG_PASSWORD}@${PG_HOST}:${PG_PORT}`;
const client = new Client({
connectionString: PG_URI,
});
client.connect(PG_URI)
.then( () =>console.log('connect to postgresdb...'))
.catch((err)=>console.log('failed connect to postgresdb:' ,err))