Edits history of script submission #5884 for ' Create a list of contacts (resend)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Resend = {
      token: string;
    };
    /**
     * Create a list of contacts
     *
     */
    export async function main(
      auth: Resend,
      body: { name: string; [k: string]: unknown }
    ) {
      const url = new URL(`https://api.resend.com/audiences`);
    
      const response = await fetch(url, {
        method: "POST",
        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 Resend = {
      token: string;
    };
    /**
     * Create a list of contacts
     *
     */
    export async function main(
      auth: Resend,
      body: { name: string; [k: string]: unknown }
    ) {
      const url = new URL(`https://api.resend.com/audiences`);
    
      const response = await fetch(url, {
        method: "POST",
        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 826 days ago