Reputation: 129
This is the code I get from the documentation at https://resend.com/docs/dashboard/audiences/contacts:
import { Resend } from 'resend';
const resend = new Resend('re_123456789');
resend.contacts.create({
email: '[email protected]',
firstName: 'Steve',
lastName: 'Wozniak',
unsubscribed: false,
audienceId: '78261eea-8f8b-4381-83c6-79fa7120f1cf',
});
This is the code I wrote in my SvelteKit app's form action:
const results = await resend.contacts.create({
email: form.data.email,
firstName: 'user', // username ?? undefined,
lastName: 'userme', // undefined,
unsubscribed: !form.data.isSubscribed,
audienceId: env.RESEND_AUDIENCE_ID,
});
Is this a problem with the Resend API? I have logged !form.data.isSubscribed several times to see what I'm sending to the API. Whether I send it as true or false, it's always created as an unsubscribed contact. Refer to the image below:
If anyone knows what I'm doing wrong here, please let me know.
Upvotes: 0
Views: 19