Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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