MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

Convert aggregation results to JSON

How can I convert my aggregation results to JSON format inside a Stitch function?

I want to do this to post them via http.

I found the answer, I’ll include here for reference. Need to include this at the end of the aggregation pipeline:

      .toArray()
      .then(docs => console.log("all documents", JSON.stringify(docs)));