Skip to content

Instantly share code, notes, and snippets.

@taddison
Created January 21, 2020 18:39
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 taddison/6ed5190fd834f1219e63d960f82adfb0 to your computer and use it in GitHub Desktop.
Save taddison/6ed5190fd834f1219e63d960f82adfb0 to your computer and use it in GitHub Desktop.
// npm install node-fetch
const fetch = require('node-fetch');
module.exports = async function (context, req) {
const body = req.rawBody || JSON.stringify({text: 'Hello World'});
if(!body) {
context.log('No request body found.');
return;
}
const forwardSlackToUri = 'http://requestbin.net/r/1frjgmd1';
const slackResponse = await fetch(forwardSlackToUri, {
method: 'POST',
body,
headers: {
'Content-Type': 'application/json',
},
});
if(!slackResponse.status === 200) {
context.log.warn(`Non-200 response code returned from Slack webhook target: ${slackResponse.status}`);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment