Edits history of script submission #14674 for ' Create Goal (clickup)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clickup = {
      token: string;
    };
    /**
     * Create Goal
     * Add a new Goal to a Workspace.
     */
    export async function main(
      auth: Clickup,
      team_id: string,
      body: {
        name: string;
        due_date: number;
        description: string;
        multiple_owners: false | true;
        owners: number[];
        color: string;
      },
    ) {
      const url = new URL(`https://api.clickup.com/api/v2/team/${team_id}/goal`);
    
      const response = await fetch(url, {
        method: "POST",
        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