Wanted to access the Payload object on a custom endpoint on a collection to send an email through Payload. Is this better suited for the local API?
What do you mean exactly? The req should have payload object on it right? And in that case you would be able to us the local API to send the email
Ah, for some reason I didn't realize the payload object is on the req!
Thanks
@281120856527077378For anyone who finds this, I did...
endpoints: [
{
path: "/verify",
method: "post",
handler: async (req, res, next) => {
try {
const msg: Message = {
from: "noreply@example.com",
to: req.body.email,
subject: "Example",
html: `The id posted was ${req.body.id}`,
};
await req.payload.sendEmail(msg);
} catch (error) {
res.json({
ok: false,
error: "Error while sending verification email.",
});
}
},
},
],
Star
Discord
online
Get dedicated engineering support directly from the Payload team.