I am facing an issue while iterating the cursor inside a webhook. The highlighted section does not work inside webhook , but works inside a standalone Nodejs program.
Also, tried cusrsor.hasNext() , not working inside webhook.
Seems that I am missing some small piece. Please let me know the possible issue/resolution.
Webhook code :
let posData = context.services.get("mongodb-atlas").db("MyDB").collection("MyCollection");
result = posData.find(body);
console.log("return document length" ,result.length);
await result.forEach(obj=>{
console.log(ojb);
});
Error:
{“message”:“‘forEach’ is not a function”}
Can you please suggest what am I missing ?