How would I go about merging these two snippets?

import mailChannelsPlugin from "@cloudflare/pages-plugin-mailchannels";

export const onRequest: PagesFunction = mailChannelsPlugin({
personalizations: [
{
to: [{ name: "Example", email: "info@example.io" }],
},
],
from: {
name: "Example",
email: "info@example.io",
},
respondWith: () => {
return new Response(
Thank you for submitting your enquiry. A member of the team will be in touch shortly.
);
},
});

const destinationURL = 'https://example.com';
const statusCode = 301;

async function handleRequest(request) {
return Response.redirect(destinationURL, statusCode);
}

addEventListener('fetch', async event => {
event.respondWith(handleRequest(event.request));
});
Was this page helpful?