a
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
"use server";
|
||||
|
||||
import { Resend } from "resend";
|
||||
|
||||
const resend = new Resend(process.env.RESEND_API_KEY);
|
||||
|
||||
export async function subscribeToNewsletter(email: string) {
|
||||
try {
|
||||
const { data, error } = await resend.contacts.create({
|
||||
email,
|
||||
audienceId: process.env.RESEND_AUDIENCE_ID!,
|
||||
});
|
||||
|
||||
if (error) {
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
|
||||
return { success: true, data };
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : "Failed to subscribe",
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user