Edits history of script submission #14699 for ' Create page (clickup)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clickup = {
      token: string;
    };
    /**
     * Create page
     * Create a page in a Doc.
     */
    export async function main(
      auth: Clickup,
      workspaceId: string,
      docId: string,
      body: {
        parent_page_id?: string;
        name?: string;
        sub_title?: string;
        content?: string;
        content_format?: string;
      },
    ) {
      const url = new URL(
        `https://api.clickup.com/api/v3/workspaces/${workspaceId}/docs/${docId}/pages`,
      );
    
      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