title: Getting Error 500 from Firestore request -
body: <p>Having issues with Firestore on NodeJS (functions). I have an API with the following:</p>
  
  <pre><code>export const getPost = (req: any, res: any): any =&gt; {
    let postData: any = {};
    postData.postId = req.params.postId;
    db.collection("posts").doc(`${req.params.postId}`)
      .get()
      .then((doc) =&gt; {
        if (!doc.exists) {
          return res.status(404).send({ error: "Post not found", success: false });
        }
        if( doc.data() &amp;&amp; postData.postId)
        {
          postData = doc.data();
        postData.postId = req.params.postId;
        let commentsRef = db.collection("comments");
        return commentsRef.orderBy("createdAt", "desc").where("postId", "==", req.params.postId).get();
        }
  
      })
      .then((data) =&gt; {
  
        if(data){
          postData.comments = [];
          data.forEach((doc: any): any =&gt; {
            postData.comments.push({ ...doc.data(), commentId: doc.id });
          });
        }
        return res.status(200).send({ data: postData, success: true });
      })
      .catch((err) =&gt; {
        res.status(500).send({ error: err, success: false });
      });
  };
  </code></pre>
  
  <p>At the moment, there are no comments. There are posts. Yet I'm getting an Error .</p>
  
  <p><code>[Error: Request failed with status code 500]</code></p>
  
  <p>Am I missing something? Pretty confused if I'm honest.</p>
  
  <p>Thanks</p>