Created
November 16, 2021 02:07
-
-
Save hieptl/81fbe141b50ca1f10511520500695177 to your computer and use it in GitHub Desktop.
users.js - routes - server - update number of posts - 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('/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