Edits history of script submission #2254 for ' Delete a team (github)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Github = {
      token: string;
    };
    /**
     * Delete a team
     * To delete a team, the authenticated user must be an organization owner or team maintainer.
    
    If you are an organization owner, deleting a parent team will delete all of its child teams as well.
    
    **Note:** You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}`.
     */
    export async function main(auth: Github, org: string, team_slug: string) {
      const url = new URL(`https://api.github.com/orgs/${org}/teams/${team_slug}`);
    
      const response = await fetch(url, {
        method: "DELETE",
        headers: {
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 367 days ago

  • nativets
    type Github = {
      token: string;
    };
    /**
     * Delete a team
     * To delete a team, the authenticated user must be an organization owner or team maintainer.
    
    If you are an organization owner, deleting a parent team will delete all of its child teams as well.
    
    **Note:** You can also specify a team by `org_id` and `team_id` using the route `DELETE /organizations/{org_id}/team/{team_id}`.
     */
    export async function main(auth: Github, org: string, team_slug: string) {
      const url = new URL(`https://api.github.com/orgs/${org}/teams/${team_slug}`);
    
      const response = await fetch(url, {
        method: "DELETE",
        headers: {
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 927 days ago