0
Delete Campaign
One script reply has been approved by the moderators Verified
Created by stephanexpsychodollxx 661 days ago Viewed 2364 times
0
Submitted by adam186 Deno
Verified 487 days ago
1
type Mailchimp = {
2
  api_key: string;
3
  server: string;
4
};
5
export async function main(auth: Mailchimp, campaign_id: string) {
6
  const url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns/${campaign_id}`;
7
  const response = await fetch(url, {
8
    method: "DELETE",
9
    headers: {
10
      Authorization: `Bearer ${auth.api_key}`,
11
    },
12
  });
13
  if (!response.ok) {
14
    throw Error(await response.text());
15
  }
16
  return `Successfully deleted campaign with ID '${campaign_id}'`;
17
}
18