Small utility wrapper around fetch to POST to Slack incoming webhooks.
- Node.js 18+ (or any environment with
fetch
available)
npm install post-message-to-slack
const postMessageToSlack = require("post-message-to-slack");
const webhookUrl = "https://hooks.slack.com/services/...";
await postMessageToSlack(webhookUrl, { text: "Hello <!here>!" });
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
Promise
with the response on success.
Type: string
The URL of the incoming webhook.
Type: object
The payload representing the message to post. See the docs on Sending messages using incoming webhooks.
Type: RequestInit
Additional settings to apply to the request.