I am working in a Web Application that connects to my PosgreSQL database, but when I go to the main page it suppose to retrieve the first element of the table actor, but is not retrieving anything, below my code. I checked the connection URL and is the correct username, password, port and database.
const express = require('express');
const bodyParser = require('body-parser');
const session = require("express-session");
const { Client } = require('pg');
const connectionString = 'postgres://postgres:12345@localhost:55306/dvdrental';
const cookieParser = require("cookie-parser");
const client = new Client({
connectionString: connectionString
});
client.connect();
const app = express();
app.use(express.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser("[mysecrethere]"));
app.use(session({
secret: "Dog",
resave: true,
saveUninitialized: true,
}));
app.get('/', function (req, res) {
client.query('SELECT * FROM actor', [1], function (err, result) {
if (err) {
console.log(err)
} else {
console.log(result);
}
});
});