Adapt request with Express for AJAX

0

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.

    
asked by anonymous 27.07.2018 / 04:38

0 answers