Toggle ON and OFF the workspace error handler for a given flow

Script windmill Verified

by admin ยท 10/22/2023

The script

Submitted by admin Typescript (fetch-only)
Verified 370 days ago
1
/**
2
 * Toggle ON and OFF the workspace error handler for a given flow
3
 *
4
 */
5
export async function main(
6
  workspace: string,
7
  path: string,
8
  body: { muted?: boolean; [k: string]: unknown }
9
) {
10
  const url = new URL(
11
    `${BASE_URL}/api/w/${workspace}/flows/toggle_workspace_error_handler/${path}`
12
  );
13

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