Edits history of script submission #10996 for ' Retrieve an Instance Size (digitalocean)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Digitalocean = {
      token: string;
    };
    /**
     * Retrieve an Instance Size
     * Retrieve information about a specific instance size for `service`, `worker`, and `job` components.
     */
    export async function main(auth: Digitalocean, slug: string) {
      const url = new URL(
        `https://api.digitalocean.com/v2/apps/tiers/instance_sizes/${slug}`,
      );
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 537 days ago