April 2020
Intermediate to advanced
716 pages
18h 55m
English
In order to complete the edit and delete expense operations initiated by signed-in users from the frontend, we need to have the corresponding APIs in the backend. The route for these API endpoints that will accept the update and delete requests can be declared in the following code.
mern-expense-tracker/server/routes/expense.routes.js:
router.route('/api/expenses/:expenseId') .put(authCtrl.requireSignin, expenseCtrl.hasAuthorization, expenseCtrl.update) .delete(authCtrl.requireSignin, expenseCtrl.hasAuthorization, expenseCtrl.remove)router.param('expenseId', expenseCtrl.expenseByID)
A PUT or DELETE request to this route will first ensure that the current user is signed in with the requireSignin ...
Read now
Unlock full access