April 2020
Intermediate to advanced
716 pages
18h 55m
English
The backend API which will return the enrollment details from the database will be defined as a GET route that accepts the request at '/api/enrollment/:enrollmentId', and will be declared as follows:
mern-classroom/server/routes/enrollment.routes.js
router.route('/api/enrollment/:enrollmentId') .get(authCtrl.requireSignin, enrollmentCtrl.isStudent, enrollmentCtrl.read)router.param('enrollmentId', enrollmentCtrl.enrollmentByID)
A GET request at this route will first invoke the enrollmentByID method, since it contains the enrollmentId param in the URL declaration. The enrolmentByID method will query the Enrollments collection by the provided ID, and if a matching enrollment document is found, we ensure that the referenced ...
Read now
Unlock full access