post-message-to-slack
v1.0.0
Published
Small utility wrapper around fetch to POST to Slack incoming webhooks
Maintainers
Readme
post-message-to-slack
Small utility wrapper around fetch to POST to Slack incoming webhooks.
Requirements
- Node.js 18+ (or any environment with
fetchavailable)
Install
npm install post-message-to-slackUsage
const postMessageToSlack = require("post-message-to-slack");
const webhookUrl = "https://hooks.slack.com/services/...";
await postMessageToSlack(webhookUrl, { text: "Hello <!here>!" });API
postMessageToSlack(webhookUrl, payload, options)
Posts the message (payload) to the proper Slack incoming webhook URL.
- Throws an error if the request fails or the response is not 2xx.
- Returns a
Promisewith the response on success.
webhookUrl
Type: string
The URL of the incoming webhook.
payload
Type: object
The payload representing the message to post. See the docs on Sending messages using incoming webhooks.
options
Type: RequestInit
Additional settings to apply to the request.
