1 | |
2 |
|
3 | type Airtable = { |
4 | apiKey: string; |
5 | }; |
6 |
|
7 | type AirtableTable = { |
8 | baseId: string; |
9 | tableName: string; |
10 | }; |
11 | export async function main( |
12 | atCon: Airtable, |
13 | atTable: AirtableTable, |
14 | recordId: string, |
15 | ) { |
16 | const url = `https://api.airtable.com/v0/${atTable.baseId}/${encodeURIComponent( |
17 | atTable.tableName, |
18 | )}/${recordId}`; |
19 |
|
20 | const response = await fetch(url, { |
21 | method: "DELETE", |
22 | headers: { |
23 | Authorization: `Bearer ${atCon.apiKey}`, |
24 | "Content-Type": "application/x-www-form-urlencoded", |
25 | }, |
26 | }); |
27 |
|
28 | if (!response.ok) { |
29 | throw new Error(`${response.status} ${await response.text()}`); |
30 | } |
31 |
|
32 | const deleteSingleRecord = await response.json(); |
33 |
|
34 | return deleteSingleRecord; |
35 | } |
36 |
|