by elisaibm866 ยท 6/6/2022
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}/actions/send`;
7
const response = await fetch(url, {
8
method: "POST",
9
headers: {
10
Authorization: `Bearer ${auth.api_key}`,
11
},
12
});
13
14
if (!response.ok) {
15
throw Error(await response.text());
16
}
17
return await response.json();
18
19