edit slack command

Script windmill Verified

by admin ยท 8/13/2023

The script

Submitted by admin Typescript (fetch-only)
Verified 370 days ago
1
/**
2
 * edit slack command
3
 *
4
 */
5
export async function main(
6
  workspace: string,
7
  body: { slack_command_script?: string; [k: string]: unknown }
8
) {
9
  const url = new URL(
10
    `${BASE_URL}/api/w/${workspace}/workspaces/edit_slack_command`
11
  );
12

13
  const response = await fetch(url, {
14
    method: "POST",
15
    headers: {
16
      "Content-Type": "application/json",
17
      Authorization: "Bearer " + WM_TOKEN,
18
    },
19
    body: JSON.stringify(body),
20
  });
21
  if (!response.ok) {
22
    const text = await response.text();
23
    throw new Error(`${response.status} ${text}`);
24
  }
25
  return await response.text();
26
}
27