1 | |
2 | type Grist = { |
3 | apiKey: string; |
4 | host: string; |
5 | }; |
6 | |
7 | * Delete a column of a table |
8 | * |
9 | */ |
10 | export async function main( |
11 | auth: Grist, |
12 | docId: string, |
13 | tableId: string, |
14 | colId: string, |
15 | ) { |
16 | const url = new URL( |
17 | `https://${auth.host}/api/docs/${docId}/tables/${tableId}/columns/${colId}`, |
18 | ); |
19 |
|
20 | const response = await fetch(url, { |
21 | method: "DELETE", |
22 | headers: { |
23 | Authorization: "Bearer " + auth.apiKey, |
24 | }, |
25 | body: undefined, |
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 |
|