April 2020
Intermediate to advanced
716 pages
18h 55m
English
In order to implement a backend API that will allow us to add and store new lessons for a given course, we first need to declare a PUT route as follows:
mern-classroom/server/routes/course.routes.js:
router.route('/api/courses/:courseId/lesson/new') .put(authCtrl.requireSignin, courseCtrl.isInstructor, courseCtrl.newLesson)
When this route gets a PUT request with the course ID in the URL, we will first use the isInstructor method to check whether the current user is the instructor for the course, and then we will save the lesson in the database with the newLesson method. The isInstructor controller method will be defined as follows:
mern-classroom/server/controllers/course.controller.js:
const isInstructor = (req, res, ...
Read now
Unlock full access