pseudosubs-v1/srv/Admin/OP/obtenerOPs.ts

28 lines
780 B
TypeScript
Raw Normal View History

2018-12-13 01:10:51 +00:00
const obtenerOPs = (req: any, res: any) => {
const con = require('../../index').conexionMySQL;
2018-12-13 01:10:51 +00:00
const YAML = require('yaml');
const animeID: number = req.params.id;
2018-12-13 01:10:51 +00:00
if (animeID) {
2018-12-13 01:10:51 +00:00
const query = `SELECT * FROM OP WHERE anime_ID=${animeID}`;
con.query( query, (err: any, resultado: object) => {
if (!err) {
2018-12-13 01:10:51 +00:00
res.send(YAML.stringify(resultado));
2018-12-13 01:10:51 +00:00
} else {
console.log("Error al ejecutar query en /Admin/OP/obtenerOPs (con.query):\n" + query + "\n" + err);
res.send("error: true");
}
});
2018-12-13 01:10:51 +00:00
} else {
console.log("Error en /Admin/OP/obtenerOPs: animeID no existe");
res.send("error: true");
}
2018-12-13 01:10:51 +00:00
};
module.exports.obtenerOPs = obtenerOPs;