小编Gop*_*ngh的帖子

slack chat.postMessage API端点不允许授权标头

我在浏览器中运行这段代码

<html>

    <script type="module">
        console.log("working");

        var url = "https://slack.com/api/chat.postMessage";
        var auth_token = "xoxb-2B"; //Your Bot's auth token
        var body = {channel: "ses", text: "testing app"}

        async function postData(url = '', data = {}) {
            // Default options are marked with *
            const response = await fetch(url, {
                method: 'POST', // *GET, POST, PUT, DELETE, etc.
                headers: {
                    "Authorization": "Bearer " + auth_token,
                    "Content-Type" : "application/json"
                },
                body: JSON.stringify(data) // body data type must match "Content-Type" header
            });
            return response.json(); // …
Run Code Online (Sandbox Code Playgroud)

javascript slack-api fetch-api

4
推荐指数
1
解决办法
1351
查看次数

标签 统计

fetch-api ×1

javascript ×1

slack-api ×1