Skip to content

Instantly share code, notes, and snippets.

@hieptl
Created November 16, 2021 02:20
Show Gist options
  • Save hieptl/fb9ff9e70fd6059db16dd0db4408c8c1 to your computer and use it in GitHub Desktop.
Save hieptl/fb9ff9e70fd6059db16dd0db4408c8c1 to your computer and use it in GitHub Desktop.
followers.js - routes - server - followers get - Instagram Clone React Node
app.post('/followers/get', (req, res) => {
const { followerId, userId } = req.body;
if (!followerId || !userId) {
res.status(200).jsonp({ message: 'Not found' });
}
const getFollowerSql = "SELECT * FROM user_follower WHERE follower_id = ? AND user_id = ?";
dbConn.query(getFollowerSql, [followerId, userId], function (error, response) {
if (response && response.length) {
res.status(200).jsonp({ ...response[0] });
} else {
res.status(200).jsonp({ message: 'Not found' });
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment