Created
January 21, 2020 18:39
-
-
Save taddison/6ed5190fd834f1219e63d960f82adfb0 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
// 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