Skip to content

Instantly share code, notes, and snippets.

@Sarav-S
Last active July 19, 2020 06:24
Show Gist options
  • Save Sarav-S/432b36ffe19092639396d9986f80ba7c to your computer and use it in GitHub Desktop.
Save Sarav-S/432b36ffe19092639396d9986f80ba7c to your computer and use it in GitHub Desktop.
const ProfileRequest = require('./app/Requests/ProfileRequest');
app.post("/profile/:id", ProfileRequest, (request, response) => {
const user = await User.findById(request.params.id);
if (!user) return response.status(404).send({ message: "User not found" });
user.name = request.body.name;
user.email = request.body.email;
await user.save();
return response.send({
message: "Profile updated successfully"
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment