sorted posts chronologically everywhere

This commit is contained in:
Aditya Sankaran
2019-12-05 19:20:05 -05:00
parent 76792148cd
commit 80a2e1894c
2 changed files with 4 additions and 1 deletions

View File

@@ -74,6 +74,7 @@ exports.getallPosts = (req, res) => {
allPosts.forEach(post => {
posts.push(post.data());
});
posts.sort((a, b) => -a.createdAt.localeCompare(b.createdAt));
resolve();
})
.catch(error => {
@@ -127,6 +128,7 @@ exports.getAlert = (req, res) => {
myPosts.forEach(function(doc) {
posts.push(doc.data());
});
posts.sort((a, b) => -a.createdAt.localeCompare(b.createdAt));
return res.status(200).json(posts);
})
.then(function() {
@@ -154,6 +156,7 @@ exports.getOtherUsersPosts = (req, res) => {
myPosts.forEach(function(doc) {
posts.push(doc.data());
});
posts.sort((a, b) => -a.createdAt.localeCompare(b.createdAt));
return res.status(200).json(posts);
})
.then(function() {