update resource

Script windmill Verified

by admin ยท 8/13/2023

The script

Submitted by admin Typescript (fetch-only)
Verified 370 days ago
1
/**
2
 * update resource
3
 *
4
 */
5
export async function main(
6
  workspace: string,
7
  path: string,
8
  body: {
9
    path?: string;
10
    description?: string;
11
    value?: unknown;
12
    [k: string]: unknown;
13
  }
14
) {
15
  const url = new URL(
16
    `${BASE_URL}/api/w/${workspace}/resources/update/${path}`
17
  );
18

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