2018-11-20 21:52:25 +00:00
|
|
|
const obtenerLinks = (req: any, res: any) => {
|
|
|
|
|
|
|
|
const con = require('../mysql').obtenerConexionMySql();
|
|
|
|
const nombre = req.body.nombre;
|
|
|
|
|
|
|
|
con.connect((err: any) => {
|
|
|
|
if (!err && nombre !== undefined) {
|
|
|
|
con.query(
|
|
|
|
`SELECT data FROM links WHERE nombre='${nombre}'`,
|
|
|
|
(err: any, response: any) => {
|
|
|
|
if (!err && response[0] ) {
|
|
|
|
|
|
|
|
const objecto = JSON.parse(response[0]["data"]);
|
|
|
|
|
|
|
|
res.send(`{ "exito": true, "payload": ${JSON.stringify(objecto)} }`);
|
|
|
|
|
2018-11-21 17:58:16 +00:00
|
|
|
} else if (!err) {
|
|
|
|
console.log("Error: La consulta no dio ningun resultado en obtenerLinks");
|
2018-11-20 21:52:25 +00:00
|
|
|
} else {
|
2018-11-21 17:58:16 +00:00
|
|
|
console.log("Error al ejecutar Query en obtenerLinks.\n" + err);
|
2018-11-20 21:52:25 +00:00
|
|
|
res.send(`{ "exito": false }`);
|
|
|
|
}
|
|
|
|
|
|
|
|
con.end();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
console.log("Hubo un error al conectarse a la base de datos :c");
|
|
|
|
res.send(`{ "exito": false }`);
|
|
|
|
|
|
|
|
con.end();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports.obtenerLinks = obtenerLinks;
|