Skip to content

Commit

Permalink
feat: Replace NextResponse with native Response (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
zenorocha authored Dec 4, 2023
1 parent 87c52bb commit f3d33fb
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/api/send/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { EmailTemplate } from '../../../components/email-template';
import { NextResponse } from 'next/server';
import { Resend } from 'resend';
import * as React from 'react';

Expand All @@ -8,18 +7,18 @@ const resend = new Resend(process.env.RESEND_API_KEY);
export async function POST() {
try {
const { data, error } = await resend.emails.send({
from: 'Acme <onboarding@resends.dev>',
from: 'Acme <onboarding@resend.dev>',
to: ['[email protected]'],
subject: "Hello world",
react: EmailTemplate({ firstName: "John" }) as React.ReactElement,
});

if (error) {
return NextResponse.json({ error });
return Response.json({ error });
}

return NextResponse.json({ data });
return Response.json({ data });
} catch (error) {
return NextResponse.json({ error });
return Response.json({ error });
}
}

0 comments on commit f3d33fb

Please sign in to comment.