1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
// called by supabase newsletter trigger (defined in sql editor)
export let addSendGridEmail = ({ token, email, listId }) =>
fetchJSON("https://api.sendgrid.com/v3/marketing/contacts", {
method: "PUT",
headers: {
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({
list_ids: [listId],
contacts: [{ email }],
}),
})
.catch((d) => {
console.email(d, `[newsletter] ${email} failed to subscribe`);
return d;
});
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
v12
October 23, 2023