I am trying to return some data that is streamed from an express server. Here is my code:
const cursor = Review.find({}).cursor();
for (let doc = await cursor.next(); doc != null; doc = await cursor.next()) {
console.log(doc);
// Prints documents one at a time
res.status(200).json(doc);
}
What is the proper way to return the data to the frontend so that doc
ends up populating an array?