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

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clickup = {
      token: string;
    };
    /**
     * Get Task Comments
     * View task comments. \
     \
    If you do not include the `start` and `start_id` parameters, this endpoint will return the most recent 25 comments.\
     \
    Use the `start` and `start id` parameters of the oldest comment to retrieve the next 25 comments.
     */
    export async function main(
      auth: Clickup,
      task_id: string,
      custom_task_ids: string | undefined,
      team_id: string | undefined,
      start: string | undefined,
      start_id: string | undefined,
    ) {
      const url = new URL(`https://api.clickup.com/api/v2/task/${task_id}/comment`);
      for (const [k, v] of [
        ["custom_task_ids", custom_task_ids],
        ["team_id", team_id],
        ["start", start],
        ["start_id", start_id],
      ]) {
        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