Slack

Slack

export const sendSlackMessage = (message) => {
    fetch(process.env.SLACK_WEBHOOK_URL, {
        method: "POST",
        headers: {
            "Content-Type": "application/json",
        },
        body: JSON.stringify({
            text: message,
        }),
    })
}

Usage

1. Create a Slack App

First, follow these instructions to create an incoming webhook.

2. How to use it

import { sendSlackMessage } from "./sendSlackMessage";

// Send the message!
sendSlackMessage("Hello world!")

Do you like my content?

Sponsor Me On Github