1 | |
2 | * executeComponent |
3 | * |
4 | */ |
5 | export async function main( |
6 | workspace: string, |
7 | path: string, |
8 | body: { |
9 | component: string; |
10 | path?: string; |
11 | args: unknown; |
12 | raw_code?: { |
13 | content: string; |
14 | language: string; |
15 | path?: string; |
16 | cache_ttl?: number; |
17 | [k: string]: unknown; |
18 | }; |
19 | force_viewer_static_fields?: { [k: string]: unknown }; |
20 | [k: string]: unknown; |
21 | } |
22 | ) { |
23 | const url = new URL( |
24 | `${BASE_URL}/api/w/${workspace}/apps_u/execute_component/${path}` |
25 | ); |
26 |
|
27 | const response = await fetch(url, { |
28 | method: "POST", |
29 | headers: { |
30 | "Content-Type": "application/json", |
31 | Authorization: "Bearer " + WM_TOKEN, |
32 | }, |
33 | body: JSON.stringify(body), |
34 | }); |
35 | if (!response.ok) { |
36 | const text = await response.text(); |
37 | throw new Error(`${response.status} ${text}`); |
38 | } |
39 | return await response.text(); |
40 | } |
41 |
|