Reputation: 237
What I want to do is having the ID of the current user into the url parameter for my Express patch method. Is it even possible to do this? I could get the ID from the Axios request but it cannot be passed without using a method. Hope anyone could enlighten me on this issue.
app.patch(`/users/edit/{id-of-the-user}`, (req, res) => {
console.log(req.body);
});
Upvotes: 1
Views: 975
Reputation: 8751
Use req.params
.
Refer to Express Routing.
app.patch(`/users/edit/:userId`, (req, res) => {
console.log(req.params.userId);
});
Upvotes: 2