Created
November 16, 2021 02:18
-
-
Save hieptl/8326a4a1f050c1a532957da454749ec5 to your computer and use it in GitHub Desktop.
posts.js - routes - server - update number of reactions - Instagram Clone React Node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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