0
edit error handler
One script reply has been approved by the moderators Verified
Created by admin 198 days ago Viewed 82 times
0
Submitted by admin Typescript (fetch-only)
Verified 198 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
    [k: string]: unknown;
11
  }
12
) {
13
  const url = new URL(
14
    `${BASE_URL}/api/w/${workspace}/workspaces/edit_error_handler`
15
  );
16

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