I am able to send the email to player1 but not player2. I know I can pass an array of strings to 'to' but then both users can see eachothers email. Any ideas? Sorry if it's a stupid question I am very new to nextjs and node
import type { NextApiRequest, NextApiResponse } from "next";
import { EmailTemplate } from "../../components/emails/EmailTemplate";
import { Resend } from "resend";
import { supabase } from "../../../initSupabase";
const resend = new Resend(process.env.NEXT_PUBLIC_RESEND_KEY);
export default async (req: NextApiRequest, res: NextApiResponse) => {
try {
const { player1, player2, player1Email, player2Email } = req.body;
const player1Data = await resend.emails.send({
from: "Acme <[email protected]>",
to: [player1Email],
subject: "Hello player 1",
react: EmailTemplate({ firstName: player1, secondName: player1Email }),
});
const player2Data = await resend.emails.send({
from: "Acme <[email protected]>",
to: [player2Email],
subject: "Hello player 2",
react: EmailTemplate({ firstName: player2, secondName: player2Email }),
});
res.status(200).json({ player1Data, player2Data });
} catch (error) {
res.status(400).json(error);
}
};