star item

Script windmill Verified

by admin ยท 8/13/2023

The script

Submitted by admin Typescript (fetch-only)
Verified 370 days ago
1
/**
2
 * star item
3
 *
4
 */
5
export async function main(
6
  workspace: string,
7
  body: {
8
    path?: string;
9
    favorite_kind?: "flow" | "app" | "script" | "raw_app";
10
    [k: string]: unknown;
11
  }
12
) {
13
  const url = new URL(`${BASE_URL}/api/w/${workspace}/favorites/star`);
14

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