Created
November 9, 2018 20:43
-
-
Save banzeh/3927d3e928804293275cd2b79522f1ff to your computer and use it in GitHub Desktop.
HTTP Post on MongoDB Stitch - IFTTT Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports = async function(args){ | |
console.log({args: args}); | |
const api_url = "https://maker.ifttt.com"; | |
const request_path = "/trigger/{webhook_event}/with/key/{your_ifttt_private_key}"; | |
const ifttt = context.services.get("your-service-name"); | |
const response = await ifttt.post({ | |
url: api_url + request_path, | |
encodeBodyAsJSON: true, | |
body: { | |
"value1": args.value1, | |
"value2": args.value2, | |
"value3": args.value3 | |
} | |
}); | |
return EJSON.parse(response.body.text()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports = function(payload, response){ | |
// Your Code Here | |
const postArgs = { | |
"value1": "Hello", | |
"value2": "World", | |
"value3": "IFTTT :D" | |
}; | |
context.functions.execute("{your-function-name}", postArgs); // Call the function and be happy :D | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment