type Mailgun = {
api_key: string;
};
export async function main(
resource: Mailgun,
data: {
listAddress: string;
query: {
address?: string;
subscribed?: boolean;
limit?: number;
skip?: number;
};
}
) {
return (
await fetch(
`https://api.mailgun.net/v3/lists/${data.listAddress}/members?${
data.query.address && `address=${data.query.address}`
}${
data.query.subscribed && `&subscribed=${data.query.subscribed}`
}&limit=${data.query.limit ?? 100}&skip=${data.query.skip ?? 0}`,
{
method: "GET",
headers: {
Authorization:
"Basic " +
Buffer.from(`api:${resource.api_key}`).toString("base64"),
},
}
)
).json();
}
Submitted by hugo697 229 days ago