April 2020
Intermediate to advanced
716 pages
18h 55m
English
To delete media from the database, we will implement a delete media API in the backend, which will accept a DELETE request from a client at /api/media/:mediaId. We will add the DELETE route for this API as follows, which will allow an authorized user to delete their uploaded media records.
mern-mediastream/server/routes/media.routes.js:
router.route('/api/media/:mediaId') .delete(authCtrl.requireSignin, mediaCtrl.isPoster, mediaCtrl.remove)
When the server receives a DELETE request at '/api/media/:mediaId', it will make sure the signed-in user is the original poster of the media by invoking the isPoster controller method. Then, the remove controller method will completely delete the specified media from the database. ...
Read now
Unlock full access