1
//native
2
type Buttondown = {
3
token: string;
4
};
5
/**
6
* Send Email To
7
*
8
*/
9
export async function main(
10
auth: Buttondown,
11
id_or_email: string,
12
email_id: string,
13
) {
14
const url = new URL(
15
`https://api.buttondown.com/v1/subscribers/${id_or_email}/emails/${email_id}`,
16
);
17
18
const response = await fetch(url, {
19
method: "POST",
20
headers: {
21
Authorization: "Token " + auth.token,
22
},
23
body: undefined,
24
});
25
if (!response.ok) {
26
const text = await response.text();
27
throw new Error(`${response.status} ${text}`);
28
}
29
return await response.json();
30
31