Skip to content

Instantly share code, notes, and snippets.

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