April 2020
Intermediate to advanced
716 pages
18h 55m
English
We will add a complete API endpoint in the backend for enrollments, which will mark specified lessons as complete, and will also mark the enrolled course as completed when all the lessons are done. To implement this API, we will start by declaring a PUT route, as shown in the following code:
mern-classroom/server/routes/enrollment.routes.js
router.route('/api/enrollment/complete/:enrollmentId') .put(authCtrl.requireSignin, enrollmentCtrl.isStudent, enrollmentCtrl.complete)
When a PUT request is received at the '/api/enrollment/complete/:enrollmentId' URL, we will first make sure that the signed-in user is the student who is associated with this enrollment record, and then we will call the complete enrollment controller ...