Edits history of script submission #1460 for ' Stop watching a snippet (bitbucket)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Stop watching a snippet
     * Used to stop watching a specific snippet. Returns 204 (No Content)
    to indicate success.
     */
    export async function main(
      auth: Bitbucket,
      encoded_id: string,
      workspace: string
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/snippets/${workspace}/${encoded_id}/watch`
      );
    
      const response = await fetch(url, {
        method: "DELETE",
        headers: {
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 375 days ago

  • nativets
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Stop watching a snippet
     * Used to stop watching a specific snippet. Returns 204 (No Content)
    to indicate success.
     */
    export async function main(
      auth: Bitbucket,
      encoded_id: string,
      workspace: string
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/snippets/${workspace}/${encoded_id}/watch`
      );
    
      const response = await fetch(url, {
        method: "DELETE",
        headers: {
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 935 days ago