Skip to content

Commit

Permalink
handle validation errors
Browse files Browse the repository at this point in the history
relates #21
  • Loading branch information
rehabas committed Mar 31, 2020
1 parent b51b111 commit ad2e957
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions server/controllers/routes/admin/cohort/addCohort.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ const {
} = require('../../../../database/queries/cohort/postCohort');
const { cohortSchema } = require('../../../../validation/cohortSchema ');

const addCohort = async (req, res, next) => {
const addCohort = async (req, res) => {
try {
await cohortSchema.validate(req.body, { abortEarly: false });
const result = await postCohort(req.body);
const { rows } = result;
const { rows } = await postCohort(req.body);
res.json({
StatusCode: 201,
data: {
Expand Down

0 comments on commit ad2e957

Please sign in to comment.