Edits history of script submission #14759 for ' Get Task (clickup)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clickup = {
      token: string;
    };
    /**
     * Get Task
     * View information about a task. You can only view task information of tasks you can access. \
     \
    Tasks with attachments will return an "attachments" response. \
     \
    Docs attached to a task are not returned.
     */
    export async function main(
      auth: Clickup,
      task_id: string,
      team_id: string | undefined,
      include_subtasks: string | undefined,
      include_markdown_description: string | undefined,
      custom_fields: string | undefined,
    ) {
      const url = new URL(`https://api.clickup.com/api/v2/task/${task_id}`);
      for (const [k, v] of [
        ["team_id", team_id],
        ["include_subtasks", include_subtasks],
        ["include_markdown_description", include_markdown_description],
        ["custom_fields", custom_fields],
      ]) {
        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