Delete a Custom Field from a board.
1
type Trello = {
2
key: string;
3
token: string;
4
};
5
/**
6
* Delete a Custom Field definition
7
* Delete a Custom Field from a board.
8
*/
9
export async function main(auth: Trello, id: string) {
10
const url = new URL(`https://api.trello.com/1/customFields/${id}`);
11
for (const [k, v] of [
12
["key", auth.key],
13
["token", auth.token],
14
]) {
15
if (v !== undefined && v !== "") {
16
url.searchParams.append(k, v);
17
}
18
19
const response = await fetch(url, {
20
method: "DELETE",
21
headers: {
22
Authorization: undefined,
23
},
24
body: undefined,
25
});
26
if (!response.ok) {
27
const text = await response.text();
28
throw new Error(`${response.status} ${text}`);
29
30
return await response.text();
31
32