Error and improvements added(fixed).

This commit is contained in:
alfredojl
2020-09-21 14:48:10 -05:00
parent 3b9a9492c2
commit ccbc286369
6 changed files with 30 additions and 27 deletions
+1 -3
View File
@@ -1,11 +1,9 @@
const get = require('./get');
const post = require('./post');
const put = require('./put');
const delet = require('./delete');
module.exports = {
get,
post,
put,
delete: delet
put
};
+16 -8
View File
@@ -20,6 +20,8 @@ const post = async(req, res) => {
const idUbicacion = req.body.idUbicacion;
const idUso = req.body.idUso;
let err = '';
await Inventario.create({
noInventario,
idActivoFijo,
@@ -28,10 +30,8 @@ const post = async(req, res) => {
idUbicacion,
idUso
})
.catch((e) => res.json({
ok: false,
error: e
}));
.then()
.catch((e) => err = e);
await Equipo.create({
modelo,
@@ -52,10 +52,18 @@ const post = async(req, res) => {
ok: true,
message: 'Equipo agregado en inventario con éxito.'
}))
.catch((e) => res.json({
ok: false,
error: e
}));
.catch(async(e) => {
await Inventario.destroy({
where: {
noInventario
}
});
res.status(500).json({
ok: false,
error: [e, err],
message: 'Equipo'
})
});
};
module.exports = post;