upstream #1

Merged
jblu merged 1007 commits from upstream into main 2024-11-04 22:35:57 -06:00
Showing only changes of commit 795d596012 - Show all commits

View File

@ -7,7 +7,9 @@ export default async (req, res) => {
try {
const API_KEY = process.env.KLAVIYO_API_KEY
const LIST_ID = process.env.KLAVIYO_LIST_ID
const response = await fetch(`https://a.klaviyo.com/api/v2/list/${LIST_ID}/subscribe?api_key=${API_KEY}`, {
const response = await fetch(
`https://a.klaviyo.com/api/v2/list/${LIST_ID}/subscribe?api_key=${API_KEY}`,
{
method: 'POST',
headers: {
Accept: 'application/json',
@ -16,11 +18,10 @@ export default async (req, res) => {
// You can add additional params here i.e. SMS, etc.
// https://developers.klaviyo.com/en/reference/subscribe
body: JSON.stringify({
profiles: [
{email: email},
]
profiles: [{ email: email }],
}),
})
}
)
if (response.status >= 400) {
return res.status(400).json({
error: `There was an error subscribing to the list.`,