Whenever I try to connect the Postgres Database from Heroku app Node.js, I'm getting H12 "Request Timeout" error. I thought it was because of response was not sent to the front end, after confirming with a function without db.query method. it is working fine. Now, Whenever we try to use db.query, the flow gets terminated. I'm new to the Heroku and Postgres Database. help me out on this
var pgp = require("./pgpromise.js");
var cn = {
host: "xxxx", // 'localhost' is the default;
port: 5432, // 5432 is the default;
database: "xxx",
user: "xxx",
password: "xxx",
};
var db = pgp(cn); // database instance;
module.exports = db;
app.post("/getaccount", async (req,res) =>{
var query = "select * from table_name";
await db.query(query, true)
.then(function (data) {
return res.json(data);
})
.catch(function (err) {
console.log("ERROR:", err); // print the error;
return res.status(400).json({ success: false, error: err });
})
});