actualizacoion proyecto final
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
const connection = require('../conf/connection.js');
|
||||
const express = require('express');
|
||||
|
||||
|
||||
var app = express()
|
||||
|
||||
function query(consulta) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
connection.query(`${consulta}`, (error, results, files) => {
|
||||
if (error) reject(error);
|
||||
resolve(results);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
app.get('/traer_datos', async(req, res) => {
|
||||
try {
|
||||
let cad = `select nombre from universidad;`;
|
||||
let uni = await query(cad);
|
||||
//console.log(respuesta);
|
||||
|
||||
cad = `select * from evento where tipo_evento='Conversatorio';`;
|
||||
let con = await query(cad);
|
||||
|
||||
cad = `select * from evento where tipo_evento='Taller alumno';`;
|
||||
let t_a = await query(cad);
|
||||
|
||||
|
||||
cad = `select * from evento where tipo_evento='Taller profesor';`;
|
||||
let t_p = await query(cad);
|
||||
|
||||
cad = `select * from evento where tipo_evento='Visitas guiadas';`;
|
||||
let v_g = await query(cad);
|
||||
|
||||
cad = `select * from evento where tipo_evento='Dialogo magistral';`;
|
||||
let d_m = await query(cad);
|
||||
|
||||
res.status(200).json({ error: false, msj: "exito", universidad: uni, conversatorio: con, taller_alumno: t_a, taller_profesor: t_p, visita: v_g, dialogo: d_m });
|
||||
return;
|
||||
} catch (err) {
|
||||
return res.status(400).json({ error: true, msj: "Error al traer los datos" });
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = app;
|
||||
Reference in New Issue
Block a user