0
edit webhook
One script reply has been approved by the moderators Verified
Created by admin 198 days ago Viewed 156 times
0
Submitted by admin Typescript (fetch-only)
Verified 198 days ago
1
/**
2
 * edit webhook
3
 *
4
 */
5
export async function main(
6
  workspace: string,
7
  body: { webhook?: string; [k: string]: unknown }
8
) {
9
  const url = new URL(`${BASE_URL}/api/w/${workspace}/workspaces/edit_webhook`);
10

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