router.get("/getCLientes",getClientes)
router.get("/getCLienteById/:id",getClienteById)
En \src\controllers\clientesControllers.js:
export const getClientes = async (req,res) => {
const [rows] = await pool.query("selectttt * from clientes")
res.json(rows)
}
export const getClienteById = async (req,res) => {
const [rows] = await pool.query("selecttttt * from clientes where id = ?", [req.params.id])
if (rows.length <= 0) {
return res.status(404).json({
"message": "Cliente no encontrado"
})
}
res.json(rows[0])
}
No hay comentarios:
Publicar un comentario