1 | |
2 | type Clickup = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Create Doc |
7 | * Create a new Doc. |
8 | */ |
9 | export async function main( |
10 | auth: Clickup, |
11 | workspaceId: string, |
12 | body: { |
13 | name?: string; |
14 | parent?: { id: string; type: number }; |
15 | visibility?: string; |
16 | create_page?: false | true; |
17 | }, |
18 | ) { |
19 | const url = new URL( |
20 | `https://api.clickup.com/api/v3/workspaces/${workspaceId}/docs`, |
21 | ); |
22 |
|
23 | const response = await fetch(url, { |
24 | method: "POST", |
25 | headers: { |
26 | "Content-Type": "application/json", |
27 | Authorization: auth.token, |
28 | }, |
29 | body: JSON.stringify(body), |
30 | }); |
31 | if (!response.ok) { |
32 | const text = await response.text(); |
33 | throw new Error(`${response.status} ${text}`); |
34 | } |
35 | return await response.json(); |
36 | } |
37 |
|