Create a gist now

Instantly share code, notes, and snippets.

@news700 /step2 Secret
Created Apr 1, 2016

What would you like to do?
exports.handler = function(event, context) {
var https = require('https');
var querystring = require('querystring');
var data = querystring.stringify({'payload': JSON.stringify({'text': 'asdf'})});
var options = {
hostname: 'hooks.slack.com',
port: 443,
path: '/services/T0KFH5M6U/B0WDKDX09/1ijK7KXJgGJC8u91LIZyLZHR',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(data)
}
};
var req = https.request(options, function(res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('Response: ' + chunk);
if (chunk == 'ok') {
context.succeed(chunk);
}
context.fail(chunk);
});
});
req.write(data);
req.end();
req.on('error', function(e) {
console.error(e);
context.fail(e);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment