Error and improvements added(fixed).
This commit is contained in:
@@ -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
|
||||
};
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user