From b45fc3640cd486c35a14c51864f977dc9791a55c Mon Sep 17 00:00:00 2001 From: shobhitm23 Date: Thu, 31 Oct 2019 15:46:40 -0400 Subject: [PATCH] changed putPost function to see postID --- functions/handlers/post.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/functions/handlers/post.js b/functions/handlers/post.js index 0054d9b..34e761a 100644 --- a/functions/handlers/post.js +++ b/functions/handlers/post.js @@ -18,10 +18,15 @@ exports.putPost = (req, res) => { }; + const resPost; + admin.firestore().collection('posts').add(newPost) .then((doc) => { - const resPost = newPost; + resPost = newPost; resPost.postId = doc.id; + return admin.firestore().doc(`posts/${doc.id}`).set(resPost) + }) + .then(() => { return res.status(200).json(resPost); }) .catch((err) => {