mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2026-03-10 21:25:04 +00:00
backend and frontend connect in progress
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
const admin = require('firebase-admin');
|
||||
/* eslint-disable promise/always-return */
|
||||
exports.putPost = (req, res) => {
|
||||
if (req.body.body.trim() === '') {
|
||||
@@ -6,18 +7,21 @@ exports.putPost = (req, res) => {
|
||||
|
||||
const newPost = {
|
||||
body: req.body.body,
|
||||
userHandle: req.user.handle,
|
||||
userImage: req.user.imageUrl,
|
||||
userHandle: req.body.userHandle,
|
||||
userImage: req.body.userImage,
|
||||
title: req.body.title,
|
||||
createdAt: new Date().toISOString(),
|
||||
likeCount: 0,
|
||||
commentCount: 0
|
||||
commentCount: 0,
|
||||
|
||||
};
|
||||
|
||||
db.collection('post').add(newPost)
|
||||
.then((doc) => {
|
||||
admin.firestore().collection('posts').add(newPost)
|
||||
.then((doc) => {
|
||||
const resPost = newPost;
|
||||
resPost.postId = doc.id;
|
||||
res.json(resPost);
|
||||
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(500).json({ error: 'something is wrong'});
|
||||
|
||||
Reference in New Issue
Block a user