Last active
February 23, 2019 16:39
-
-
Save cplankey/e95e976758cfa0abd455e1e8f12d338b to your computer and use it in GitHub Desktop.
A simple node module that takes a hostname, path, and msg to post to Slack from a Lambda Layer
This file contains hidden or 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
//Takes a hostname, path, and msg to post to slack | |
var https = require("https"); | |
exports.posttoslack = function(hostname, path, msg){ | |
return new Promise((resolve, reject) => { | |
var options = { | |
"method": "POST", | |
"hostname": hostname, | |
"path": path, | |
"headers": { | |
"Content-Type": "application/json" | |
} | |
}; | |
var req = https.request(options, (res) => { | |
resolve('Success'); | |
}); | |
req.on('error', (e) => { | |
reject(e.message); | |
}); | |
// send the request | |
req.write(JSON.stringify({ text: msg })); | |
req.end(); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment