Delete Campaign

Script mailchimp Verified

by stephanexpsychodollxx ยท 6/6/2022

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 3 days ago
1
//native
2

3
type Mailchimp = {
4
  api_key: string;
5
  server: string;
6
};
7
export async function main(auth: Mailchimp, campaign_id: string) {
8
  const url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns/${campaign_id}`;
9
  const response = await fetch(url, {
10
    method: "DELETE",
11
    headers: {
12
      Authorization: `Bearer ${auth.api_key}`,
13
    },
14
  });
15
  if (!response.ok) {
16
    throw Error(await response.text());
17
  }
18
  return `Successfully deleted campaign with ID '${campaign_id}'`;
19
}
20

Other submissions
  • Submitted by adam186 Deno
    Created 395 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