1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Node.jsからDiscordに通知を送るメモ(Fetch API)

Last updated at Posted at 2022-12-07

前書いた記事のFetch版です。

基本は一緒

'use strict'

const URL = `DISCORD_WEBHOOK_URL`;

//送信するデータ
const postData = {
    username: 'n0bisuke BOT',
    content: 'Node.js Fetch APIからポスト'
}

const main = async () => {
    const response = await fetch(URL, {
        method: 'POST',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json',
        },
        body: JSON.stringify(postData)
    });

    // const json = await response.json();
    console.log(response.status);
}

main();

スクリーンショット 2022-12-07 20.51.44.png

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?