Skip to content

Instantly share code, notes, and snippets.

@hieptl
Created November 16, 2021 02:07
Show Gist options
  • Save hieptl/81fbe141b50ca1f10511520500695177 to your computer and use it in GitHub Desktop.
Save hieptl/81fbe141b50ca1f10511520500695177 to your computer and use it in GitHub Desktop.
users.js - routes - server - update number of posts - Instagram Clone React Node
app.post('/users/posts', (req, res) => {
const { numberOfPosts, id } = req.body;
const updateNumberOfPostsSql = "UPDATE user_account SET user_number_of_posts = ? WHERE id = ?";
dbConn.query(updateNumberOfPostsSql, [numberOfPosts, id], function (err, updatedUser) {
if (err) {
res.status(200).jsonp({ message: "The system error. Please try again" });
} else if (updatedUser) {
res.status(200).jsonp({ id });
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment