1 |
|
2 | * list folder names |
3 | * |
4 | */ |
5 | export async function main( |
6 | workspace: string, |
7 | only_member_of: string | undefined |
8 | ) { |
9 | const url = new URL(`${BASE_URL}/api/w/${workspace}/folders/listnames`); |
10 | for (const [k, v] of [["only_member_of", only_member_of]]) { |
11 | if (v !== undefined && v !== "") { |
12 | url.searchParams.append(k, v); |
13 | } |
14 | } |
15 | const response = await fetch(url, { |
16 | method: "GET", |
17 | headers: { |
18 | Authorization: "Bearer " + WM_TOKEN, |
19 | }, |
20 | body: undefined, |
21 | }); |
22 | if (!response.ok) { |
23 | const text = await response.text(); |
24 | throw new Error(`${response.status} ${text}`); |
25 | } |
26 | return await response.json(); |
27 | } |
28 |
|