Skip to content

Instantly share code, notes, and snippets.

@thomaszurkan-optimizely
Created July 30, 2018 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomaszurkan-optimizely/af24b860d4a061daac0464a88c13ee85 to your computer and use it in GitHub Desktop.
Save thomaszurkan-optimizely/af24b860d4a061daac0464a88c13ee85 to your computer and use it in GitHub Desktop.
function sendWebhook(data, done) {
var url = 'https://hooks.slack.com/services/LONG_UNIQUE_KEY';
const options = {
hostname: 'hooks.slack.com',
protocol: 'https:',
//port: 80,
path: '/services/LONG_UNIQUE_KEY',
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
};
const req = http.request(options, (res) => {
res.setEncoding('utf8');
res.on('data', (chunk) => {
console.log(`BODY: ${chunk}`);
});
res.on('end', () => {
console.log('No more data in response.');
});
});
req.on('error', (e) => {
console.error(`problem with request: ${e.message}`);
});
req.write(data);
req.end();
done(null, {'result' :'200'})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment