Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
exports = function(changeEvent) {
const http = context.services.get("salesHTTP");
const fullDocument = changeEvent.fullDocument;
return http.post({
url: "https://api.pushover.net/1/messages.json",
body: {
token: context.values.get("PUSHOVER_API_TOKEN"),
user: context.values.get("PUSHOVER_USER"),
title: 'New Sale',
message:`${fullDocument.productName} - ${fullDocument.price}`,
sound: 'cashregister'
},
encodeBodyAsJSON: true
})
.then(response => {
// The response body is encoded as raw BSON.Binary. Parse it to JSON.
const ejson_body = EJSON.parse(response.body.text());
return ejson_body;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment