Edits history of script submission #12013 for ' List all instance domains (clerk)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clerk = {
      apiKey: string;
    };
    /**
     * List all instance domains
     * Use this endpoint to get a list of all domains for an instance.
    The response will contain the primary domain for the instance and any satellite domains. Each domain in the response contains information about the URLs where Clerk operates and the required CNAME targets.
     */
    export async function main(auth: Clerk) {
      const url = new URL(`https://api.clerk.com/v1/domains`);
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Bearer " + auth.apiKey,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 428 days ago