so this is my code
const url = `postgres://.......`;
const pg =require (`pg`);
const client =new pg.Client(url);
app.get("/data", handeldata)
function handeldata(req ,res ){
let sql = 'select * from houses ;'
client.query(sql).then((results)=>{
res.send(results.rows);
}).catch((err)=>{
console.log(err);
})
}
there is no error massage only the respone on thunder is reloading or not recived and i tried to console log inside the function but it did not see it ?
You forgot to create the connection:
client.connect(); //<=====
app.get("/data", handledata);
function handledata(req, res) {
let sql = "select * from houses ;";
client
.query(sql)
.then((results) => {
res.send(results.rows);
})
.catch((err) => {
res.send(err);
});
}