type Trello = {
key: string;
token: string;
};
/**
* Batch Requests
* Make up to 10 GET requests in a single, batched API call.
*/
export async function main(auth: Trello, urls: string | undefined) {
const url = new URL(`https://api.trello.com/1/batch`);
for (const [k, v] of [
["urls", urls],
["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 71 days ago
type Trello = {
key: string;
token: string;
};
/**
* Batch Requests
* Make up to 10 GET requests in a single, batched API call.
*/
export async function main(auth: Trello, urls: string | undefined) {
const url = new URL(`https://api.trello.com/1/batch`);
for (const [k, v] of [
["urls", urls],
["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 626 days ago