I’m trying to send an array over HTTP POST, it’s sending just an empty response. When I return the array to the console, it’s full. Any clue what’s going here?
exports = function() {
const mongodbAtlas = context.services.get("mongodb-atlas");
const auctions = mongodbAtlas.db("myFirstDatabase").collection("items");
//Date now
var now = new Date();
//Get customer with last bid
const findHighestBidder = auctions.aggregate([
{$match: { $and: [
{endDate: {$lt: now}},
{status: "active" }
] }},
{ $project : { status: 1, bidHistory: 1 } },
{$addFields : {bidHistory : {$reduce : {
input : "$bidHistory",
initialValue : {bid : 0},
in : {$cond: [{$gte : ["$$this.bid", "$$value.bid"]},"$$this", "$$value"]}}
}}}
])
const result = findHighestBidder.toArray
//This returns the results as expected
return result
//This returns: "{ results: {} }"
return context.http.post({
url: "http://27b1e5a30df2.ngrok.io/api/stripe/test",
body: {result} ,
encodeBodyAsJSON: true
})
};