It is possible from a request using express, convert it to ajax, or even if you can merge them. Example:
app.get('/alunos',(req,res) => {
const client = new Client();
client.connect()
.then(() => {
return client.query('SELECT id,nome FROM aluno');
})
.then((results) => {
console.log('results?',results);
res.render('aluno-list',results);
})
.catch((err) => {
console.log('error',err);
res.send('deu ruim aqui');
});
});
This function has AJAX behavior.