Skip to content

Commit

Permalink
convert promise to async/await in deleteCohort.js
Browse files Browse the repository at this point in the history
relates #29
  • Loading branch information
MohammedAlghazali committed Mar 30, 2020
1 parent 9bbdfdf commit fa8c6f0
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions server/controllers/routes/admin/cohort/deleteCohort.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
const deleteCohort = require('../../../../database/queries/cohort/deleteCohort');

const cohortDelete = (req, res, next) => {
deleteCohort(req.params.cohortId)
.then(() =>
res.json({
StatusCode: 200,
data: { message: 'Cohort deleted successfully' },
}),
)
.catch(next);
const cohortDelete = async (req, res, next) => {
try {
await deleteCohort(req.params.cohortId);
res.json({
StatusCode: 200,
data: { message: 'Cohort deleted successfully' },
});
} catch (err) {
next(err);
}
};

module.exports = {
Expand Down

0 comments on commit fa8c6f0

Please sign in to comment.