-
-
Save cyberplanner/4069a48d14360df6f0c1c4c2548c7f8d to your computer and use it in GitHub Desktop.
Post to Slack using javascript
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
// https://googlechrome.github.io/samples/fetch-api/fetch-post.html | |
var request = new Request('https://hooks.slack.com/services/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', { | |
method: 'POST', | |
body: JSON.stringify({text: 'Hello'}), | |
headers: new Headers({'Content-type': 'application/json'}) | |
}); | |
fetch(request).then(function(response) { console.log(response)}); |
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
var url = // Webhook URL | |
var text = // Text to post | |
$.ajax({ | |
data: 'payload=' + JSON.stringify({ | |
"text": text | |
}), | |
dataType: 'json', | |
processData: false, | |
type: 'POST', | |
url: url | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment