Edits history of script submission #15989 for ' Enable integration dev mode (gitbook)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Gitbook = {
      token: string;
    };
    /**
     * Enable integration dev mode
     *
     */
    export async function main(
      auth: Gitbook,
      integrationName: string,
      body: { tunnelUrl: string; all?: false | true },
    ) {
      const url = new URL(`https://api.gitbook.com/v1/integrations/${integrationName}/dev`);
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 235 days ago