Created
July 30, 2018 23:17
-
-
Save thomaszurkan-optimizely/af24b860d4a061daac0464a88c13ee85 to your computer and use it in GitHub Desktop.
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
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