Express App with PostgreSQL Connection & CORS Configuration

Language: JavaScript
Author: Guest
Comments: 0
Useful:

Code:

Details:

Your Ad Here

Solution:

It appears that the code you provided is missing a closing curly brace and parenthesis at the end of the code snippet. Additionally, there seems to be a missing closing parenthesis for the `res.json` function. Let's correct these issues:

javascript
const result = await pool.query('SELECT NOW()');
res.json({
message: 'Conexión exitosa a PostgreSQL',
// Muestra la fecha y hora de la consulta
time: result.rows[0].now
});
});

app.listen(3000, () => {
console.log('Servidor iniciado en http://localhost:3000');
});
In this corrected version, I closed the curly brace for the `app.get` function and added an additional closing parenthesis for the `res.json` function. I also added a closing parenthesis for the `app.get` function.


Comments:

Login to leave your comments!