Edits history of script submission #14006 for ' Creates a queue (ably)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Ably = {
      accessToken: string;
    };
    /**
     * Creates a queue
     * Creates a queue for the application specified by application ID. The properties for the queue to be created are specified in the request body.
     */
    export async function main(
      auth: Ably,
      app_id: string,
      body: { name: string; ttl: number; maxLength: number; region: string },
    ) {
      const url = new URL(`https://control.ably.net/v1/apps/${app_id}/queues`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.accessToken,
        },
        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 220 days ago