type Trello = {
key: string;
token: string;
};
/**
* Get a Checklist
*
*/
export async function main(
auth: Trello,
id: string,
cards: "all" | "closed" | "none" | "open" | "visible" | undefined,
checkItems: "all" | "none" | undefined,
checkItem_fields:
| "all"
| "name"
| "nameData"
| "pos"
| "state"
| "type"
| "due"
| "dueReminder"
| "idMember"
| undefined,
fields: string | undefined
) {
const url = new URL(`https://api.trello.com/1/checklists/${id}`);
for (const [k, v] of [
["cards", cards],
["checkItems", checkItems],
["checkItem_fields", checkItem_fields],
["fields", fields],
["key", auth.key],
["token", auth.token],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: undefined,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 399 days ago
type Trello = {
key: string;
token: string;
};
/**
* Get a Checklist
*
*/
export async function main(
auth: Trello,
id: string,
cards: "all" | "closed" | "none" | "open" | "visible" | undefined,
checkItems: "all" | "none" | undefined,
checkItem_fields:
| "all"
| "name"
| "nameData"
| "pos"
| "state"
| "type"
| "due"
| "dueReminder"
| "idMember"
| undefined,
fields: string | undefined
) {
const url = new URL(`https://api.trello.com/1/checklists/${id}`);
for (const [k, v] of [
["cards", cards],
["checkItems", checkItems],
["checkItem_fields", checkItem_fields],
["fields", fields],
["key", auth.key],
["token", auth.token],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: undefined,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 953 days ago