Cloudflare mailchannels dynamic name

Does someone know how can i set the from field dynamically from the one i have in the form (id=name)? Or any way I can debug to see the actual payload,
https://developers.cloudflare.com/pages/functions/api-reference/#onrequests I'm guessing it's either in the data or in the request, but I'd rather not trying blindly. Thanks
import mailChannelsPlugin from "@cloudflare/pages-plugin-mailchannels";
export const onRequest: PagesFunction = (context) => {
var data = context?.data; // <-- That's just a test

return mailChannelsPlugin({
personalizations: [
{
to: [{ name: "Giulio Zanchetta", email: "[email protected]" }],
dkim_domain: "majestico.it",
dkim_selector: "mailchannels",
dkim_private_key: context.env.DKIM_PRIVATE_KEY,
},
],
from: {
name: `${data?.name}`, // <-- Here I want the actual name inserted in the form
},
respondWith: () =>
new Response(null, {
status: 302,
headers: { Location: "/thank-you" },
}),
})(context);
};
import mailChannelsPlugin from "@cloudflare/pages-plugin-mailchannels";
export const onRequest: PagesFunction = (context) => {
var data = context?.data; // <-- That's just a test

return mailChannelsPlugin({
personalizations: [
{
to: [{ name: "Giulio Zanchetta", email: "[email protected]" }],
dkim_domain: "majestico.it",
dkim_selector: "mailchannels",
dkim_private_key: context.env.DKIM_PRIVATE_KEY,
},
],
from: {
name: `${data?.name}`, // <-- Here I want the actual name inserted in the form
},
respondWith: () =>
new Response(null, {
status: 302,
headers: { Location: "/thank-you" },
}),
})(context);
};
API reference · Cloudflare Pages docs
Learn about the APIs used within Pages Functions.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server