April 2020
Intermediate to advanced
716 pages
18h 55m
English
We will implement a create media API in the backend to allow users to create new media posts on the application. This API will receive a POST request at '/api/media/new/:userId' with the multipart body content containing the media fields and the uploaded video file. First, we will declare the create media route and utilize the userByID method from the user controller, as shown in the following code.
mern-mediastream/server/routes/media.routes.js:
router.route('/api/media/new/:userId') .post(authCtrl.requireSignin, mediaCtrl.create)router.param('userId', userCtrl.userByID)
The userByID method processes the :userId parameter that's passed in the URL and retrieves the associated user from the database. The user object becomes ...
Read now
Unlock full access