Edits history of script submission #22439 for ' Send a Campaign (mailchimp)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    type Mailchimp = {
      api_key: string;
      server: string;
    };
    export async function main(auth: Mailchimp, campaign_id: string) {
      const url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns/${campaign_id}/actions/send`;
      const response = await fetch(url, {
        method: "POST",
        headers: {
          Authorization: `Bearer ${auth.api_key}`,
        },
      });
    
      if (!response.ok) {
        throw Error(await response.text());
      }
      return await response.json();
    }
    

    Submitted by hugo989 7 days ago