Skip to content

Instantly share code, notes, and snippets.

@hieptl
Created November 16, 2021 02:13
Show Gist options
  • Save hieptl/07b8c15e4f0ec64eb539173f4cdd21cd to your computer and use it in GitHub Desktop.
Save hieptl/07b8c15e4f0ec64eb539173f4cdd21cd to your computer and use it in GitHub Desktop.
posts.js - routes - server - Instagram Clone React Node
app.get('/posts', (req, res) => {
const getPostsSql = "SELECT * FROM post ORDER BY post_created_date DESC";
dbConn.query(getPostsSql, function (error, posts) {
if (posts) {
res.status(200).jsonp(posts);
} else {
res.status(200).jsonp({ message: 'Cannot get your posts, please try again' });
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment