Edits history of script submission #14810 for ' Update Goal (clickup)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clickup = {
      token: string;
    };
    /**
     * Update Goal
     * Rename a Goal, set the due date, replace the description, add or remove owners, and set the Goal color.
     */
    export async function main(
      auth: Clickup,
      goal_id: string,
      body: {
        name: string;
        due_date: number;
        description: string;
        rem_owners: number[];
        add_owners: number[];
        color: string;
      },
    ) {
      const url = new URL(`https://api.clickup.com/api/v2/goal/${goal_id}`);
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago