Package Exports
- post-message-to-slack
- post-message-to-slack/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (post-message-to-slack) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
post-message-to-slack
Small utility wrapper around fetch to POST to Slack incoming webhooks.
Requirements
- Node.js 18+ (or any environment with
fetch
available)
Install
npm install post-message-to-slack
Usage
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
Promise
with 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.