type Trello = {
key: string;
token: string;
};
/**
* Get a Webhook belonging to a Token
* Retrieve a webhook created with a Token.
*/
export async function main(auth: Trello, token: string, idWebhook: string) {
const url = new URL(
`https://api.trello.com/1/tokens/${token}/webhooks/${idWebhook}`
);
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 398 days ago
type Trello = {
key: string;
token: string;
};
/**
* Get a Webhook belonging to a Token
* Retrieve a webhook created with a Token.
*/
export async function main(auth: Trello, token: string, idWebhook: string) {
const url = new URL(
`https://api.trello.com/1/tokens/${token}/webhooks/${idWebhook}`
);
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