Professional Documents
Culture Documents
User Code Text
User Code Text
} catch (error){
res.sendStatus(400);
}
});
usersRouter.delete('/courses/drop/:id',async(req,res,next)=>{
const id = req.params.id;
const course = await Course.findById(id);
try{
if(!course.isApplied){
return res.status(403).send({error:"You have not enrolled for this
course"});
}
course.isApplied= false;
await course.save();
return res.status(200).send({message: "You have dropped the course"});
} catch (error){
res.sendStatus(400);
}
});
usersRouter.get('/courses/get',async(req,res,next)=>{
try {
const courses = await Course.find();
return res.status(200).send(courses);
} catch (error) {
res.sendStatus(400);
}
});
}
});
module.exports = usersRouter;