0

Update an Action

by
Published Oct 30, 2023

Update a specific Action. Only comment actions can be updated. Used to edit the content of a comment.

Script trello Verified

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 398 days ago
1
type Trello = {
2
  key: string;
3
  token: string;
4
};
5
/**
6
 * Update an Action
7
 * Update a specific Action. Only comment actions can be updated. Used to edit the content of a comment.
8
 */
9
export async function main(auth: Trello, id: string, text: string | undefined) {
10
  const url = new URL(`https://api.trello.com/1/actions/${id}`);
11
  for (const [k, v] of [
12
    ["text", text],
13
    ["key", auth.key],
14
    ["token", auth.token],
15
  ]) {
16
    if (v !== undefined && v !== "") {
17
      url.searchParams.append(k, v);
18
    }
19
  }
20
  const response = await fetch(url, {
21
    method: "PUT",
22
    headers: {
23
      Authorization: undefined,
24
    },
25
    body: undefined,
26
  });
27
  if (!response.ok) {
28
    const text = await response.text();
29
    throw new Error(`${response.status} ${text}`);
30
  }
31
  return await response.text();
32
}
33