Edits history of script submission #3061 for ' Get Member's Organizations (trello)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Trello = {
      key: string;
      token: string;
    };
    /**
     * Get Member's Organizations
     * Get a member's Workspaces
     */
    export async function main(
      auth: Trello,
      id: string,
      filter: "all" | "members" | "none" | "public" | undefined,
      fields: "id" | "name" | undefined,
      paid_account: string | undefined
    ) {
      const url = new URL(`https://api.trello.com/1/members/${id}/organizations`);
      for (const [k, v] of [
        ["filter", filter],
        ["fields", fields],
        ["paid_account", paid_account],
        ["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 399 days ago

  • nativets
    type Trello = {
      key: string;
      token: string;
    };
    /**
     * Get Member's Organizations
     * Get a member's Workspaces
     */
    export async function main(
      auth: Trello,
      id: string,
      filter: "all" | "members" | "none" | "public" | undefined,
      fields: "id" | "name" | undefined,
      paid_account: string | undefined
    ) {
      const url = new URL(`https://api.trello.com/1/members/${id}/organizations`);
      for (const [k, v] of [
        ["filter", filter],
        ["fields", fields],
        ["paid_account", paid_account],
        ["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