Edits history of script submission #1900 for ' Update a project (github)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Github = {
      token: string;
    };
    /**
     * Update a project
     * Updates a project board's information. Returns a `404 Not Found` status if projects are disabled. If you do not have sufficient privileges to perform this action, a `401 Unauthorized` or `410 Gone` status is returned.
     */
    export async function main(
      auth: Github,
      project_id: string,
      body: {
        body?: string;
        name?: string;
        organization_permission?: "read" | "write" | "admin" | "none";
        private?: boolean;
        state?: string;
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://api.github.com/projects/${project_id}`);
    
      const response = await fetch(url, {
        method: "PATCH",
        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.json();
    }
    

    Submitted by hugo697 399 days ago

  • nativets
    type Github = {
      token: string;
    };
    /**
     * Update a project
     * Updates a project board's information. Returns a `404 Not Found` status if projects are disabled. If you do not have sufficient privileges to perform this action, a `401 Unauthorized` or `410 Gone` status is returned.
     */
    export async function main(
      auth: Github,
      project_id: string,
      body: {
        body?: string;
        name?: string;
        organization_permission?: "read" | "write" | "admin" | "none";
        private?: boolean;
        state?: string;
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://api.github.com/projects/${project_id}`);
    
      const response = await fetch(url, {
        method: "PATCH",
        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.json();
    }
    

    Submitted by hugo697 959 days ago