Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

use resend in server action (via REST)

Steven Tey4c7329597327
diff --git a/app/ui/stats/feedback/action.ts b/app/ui/stats/feedback/action.ts
index 7fa1d057d4..a0975b46e8 100644
--- a/app/ui/stats/feedback/action.ts
+++ b/app/ui/stats/feedback/action.ts
@@ -1,13 +1,22 @@
"use server";
-import { log } from "#/lib/utils";
-
export async function submitFeedback(data: FormData) {
const email = data.get("email") as string;
const feedback = data.get("feedback") as string;
- return await log({
- message: `New feedback from *${email}*: ${feedback}`,
- type: "cron",
+ return await fetch("https://api.resend.com/emails", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: "Bearer " + process.env.RESEND_API_KEY,
+ },
+ body: JSON.stringify({
+ reply_to: email,
+ ...(email && { reply_to: email }),
+ subject: "🎉 New Feedback Received!",
+ text: feedback,
+ }),
});
}