type Trello = {
key: string;
token: string;
};
/**
* Get a specific field on an Action
* Get a specific property of an action
*/
export async function main(
auth: Trello,
id: string,
field:
| "id"
| "idMemberCreator"
| "data"
| "type"
| "date"
| "limits"
| "display"
| "memberCreator"
) {
const url = new URL(`https://api.trello.com/1/actions/${id}/${field}`);
for (const [k, v] of [
["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.json();
}
Submitted by hugo697 399 days ago
type Trello = {
key: string;
token: string;
};
/**
* Get a specific field on an Action
* Get a specific property of an action
*/
export async function main(
auth: Trello,
id: string,
field:
| "id"
| "idMemberCreator"
| "data"
| "type"
| "date"
| "limits"
| "display"
| "memberCreator"
) {
const url = new URL(`https://api.trello.com/1/actions/${id}/${field}`);
for (const [k, v] of [
["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.json();
}
Submitted by hugo697 953 days ago