0
edit error handler
One script reply has been approved by the moderators Verified
Created by admin 276 days ago Viewed 6589 times
0
Submitted by admin Typescript (fetch-only)
Verified 276 days ago
1
/**
2
 * edit error handler
3
 *
4
 */
5
export async function main(
6
  workspace: string,
7
  body: {
8
    error_handler?: string;
9
    error_handler_extra_args?: { [k: string]: unknown };
10
    error_handler_muted_on_cancel?: boolean;
11
    [k: string]: unknown;
12
  }
13
) {
14
  const url = new URL(
15
    `${BASE_URL}/api/w/${workspace}/workspaces/edit_error_handler`
16
  );
17

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