Commit fc1f4277 authored by Vytor Calixto's avatar Vytor Calixto 👾

Add error 400 when processing body in classroom count

parent 25c6c381
Pipeline #15035 failed with stage
in 7 minutes and 47 seconds
......@@ -208,7 +208,12 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
let classSize = JSON.parse(req.body.class_size) || null;
let integralTime = JSON.parse(req.body.integral_time) || null;
// console.log(classSize, integralTime);
console.log(classSize, integralTime);
if(classSize == null || integralTime == null) {
res.statusCode = 400;
return res.json({err: {message: "There was an error processing class_size or integral_time. Check your JSON sintax and be sure you're sending both paramenters."}});
}
req.classroom = req.result;
let classroom = [];
......@@ -279,10 +284,10 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
let size = classSize.find((el) => {
return el.id === eduLevel.education_level_short_id;
});
}) || undefined;
let fullPeriodTime = integralTime.find((el) => {
return el.id === eduLevel.education_level_short_id;
});
}) || undefined;
if(typeof size === 'undefined' || typeof fullPeriodTime === 'undefined') return;
size = size.numberStudentClass;
......@@ -320,7 +325,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
result.push(r);
});
// console.log('FEITO');
console.log('FEITO');
req.result = result;
next();
}, response('classroom_count'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment