Edits history of script submission #14746 for ' Get Groups (clickup)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clickup = {
      token: string;
    };
    /**
     * Get Groups
     * This endpoint is used to view [User Groups](https://docs.clickup.com/en/articles/4010016-teams-how-to-create-user-groups) in your Workspace.\
     \
    In our API documentation, `team_id` refers to the ID of a Workspace, and `group_id` refers to the ID of a User Group.
     */
    export async function main(
      auth: Clickup,
      team_id: string | undefined,
      group_ids: string | undefined,
    ) {
      const url = new URL(`https://api.clickup.com/api/v2/group`);
      for (const [k, v] of [
        ["team_id", team_id],
        ["group_ids", group_ids],
      ]) {
        if (v !== undefined && v !== "" && k !== undefined) {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago