From ff5e87185da5257f27fbcb3bf9b568a5cf682144 Mon Sep 17 00:00:00 2001 From: mu7ammadabed Date: Wed, 1 Apr 2020 22:29:15 +0300 Subject: [PATCH] Edit destructure --- server/controllers/routes/admin/cohort/editCohort.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/controllers/routes/admin/cohort/editCohort.js b/server/controllers/routes/admin/cohort/editCohort.js index c18c4026..fe922e51 100644 --- a/server/controllers/routes/admin/cohort/editCohort.js +++ b/server/controllers/routes/admin/cohort/editCohort.js @@ -4,8 +4,12 @@ const { editCohortSchema } = require('../../../../validation/index'); const editCohort = async (req, res, next) => { try { const { cohortId } = req.params; - const data = { ...req.body, cohortId }; - await editCohortSchema.validate(data, { abortEarly: false }); + const data = await editCohortSchema.validate( + { ...req.body, cohortId }, + { + abortEarly: false, + }, + ); const result = await putSpecificCohort(data); if (result.rowCount === 1) { res.json({ statusCode: 200, message: 'Changed Succefully' });