mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2026-03-10 13:15:05 +00:00
added get request userline function
This commit is contained in:
@@ -26,3 +26,20 @@ exports.putPost = (req, res) => {
|
||||
});
|
||||
};
|
||||
|
||||
exports.getallPostsforUser = (req, res) => {
|
||||
|
||||
admin.firestore().collection('posts').where('userHandle', '==', 'user' ).get()
|
||||
.then((data) => {
|
||||
let posts = [];
|
||||
data.forEach(function(doc) {
|
||||
posts.push(doc.data());
|
||||
});
|
||||
return res.status(200).json(posts);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
return res.status(500).json({error: 'Failed to fetch all posts written by specific user.'})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,8 +24,9 @@ app.post('/updateProfileInfo', updateProfileInfo);
|
||||
/*------------------------------------------------------------------*
|
||||
* handlers/post.js *
|
||||
*------------------------------------------------------------------*/
|
||||
const {putPost} = require('./handlers/post');
|
||||
const {putPost, getallPostsforUser} = require('./handlers/post');
|
||||
|
||||
app.get('/getallPostsforUser', getallPostsforUser);
|
||||
|
||||
// Adds one post to the database
|
||||
app.post('/putPost', fbAuth, putPost);
|
||||
|
||||
Reference in New Issue
Block a user