Created
November 16, 2021 02:13
-
-
Save hieptl/07b8c15e4f0ec64eb539173f4cdd21cd to your computer and use it in GitHub Desktop.
posts.js - routes - server - 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.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