Edits history of script submission #14726 for ' Edit page (clickup)'

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