type Trello = {
key: string;
token: string;
};
/**
* Create Reaction for Action
* Adds a new reaction to an action
*/
export async function main(
auth: Trello,
idAction: string,
body: {
shortName?: string;
skinVariation?: string;
native?: string;
unified?: string;
[k: string]: unknown;
}
) {
const url = new URL(`https://api.trello.com/1/actions/${idAction}/reactions`);
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: "POST",
headers: {
"Content-Type": "application/json",
Authorization: undefined,
},
body: JSON.stringify(body),
});
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;
};
/**
* Create Reaction for Action
* Adds a new reaction to an action
*/
export async function main(
auth: Trello,
idAction: string,
body: {
shortName?: string;
skinVariation?: string;
native?: string;
unified?: string;
[k: string]: unknown;
}
) {
const url = new URL(`https://api.trello.com/1/actions/${idAction}/reactions`);
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: "POST",
headers: {
"Content-Type": "application/json",
Authorization: undefined,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 953 days ago