我在浏览器中运行这段代码
<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)