I am trying to extract information from mongo shell and send it to a remote api server. I attempted the following code since mongo shell includes an embedded javascript interpreter called spider monkey:
// myscript.js
db.aggregate([ { $currentOp: {} }])
.forEach(function(doc) {
// My goal is to send each doc to a remote api server.
let http = new XMLHttpRequest();
http.open('POST', url);
http.send(doc);
})
and
mongo myscript.js
The method above did not work as XMLHttpRequest is not defined. Is there a workaround for this issue?