0

Get the Member of an Action

by
Published Oct 30, 2023

Gets the member of an action (not the creator)

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
 * Get the Member of an Action
7
 * Gets the member of an action (not the creator)
8
 */
9
export async function main(auth: Trello, id: string, fields: "id" | undefined) {
10
  const url = new URL(`https://api.trello.com/1/actions/${id}/member`);
11
  for (const [k, v] of [
12
    ["fields", fields],
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: "GET",
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.json();
32
}
33