Stop waiting for email to send when handling contact form submission
All checks were successful
release / Publish to Cloudflare Pages (push) Successful in 1m32s
All checks were successful
release / Publish to Cloudflare Pages (push) Successful in 1m32s
This commit is contained in:
@@ -28,17 +28,17 @@ export const onRequest: PagesFunction<Env> = (context) => {
|
|||||||
|
|
||||||
// Must have some kind of identifiable information for me to actually care about them.
|
// Must have some kind of identifiable information for me to actually care about them.
|
||||||
if ((fullName || email) && message) {
|
if ((fullName || email) && message) {
|
||||||
try {
|
// Don't await response so the client doesn't have to wait for email to send as it
|
||||||
await context.env.SERVICE.sendEmail({
|
// feels unresponsive
|
||||||
|
context.env.SERVICE.sendEmail({
|
||||||
fullName,
|
fullName,
|
||||||
organisation,
|
organisation,
|
||||||
email,
|
email,
|
||||||
mobile,
|
mobile,
|
||||||
message,
|
message,
|
||||||
});
|
})
|
||||||
} catch (e) {
|
.then(() => console.log("Sent email"))
|
||||||
return new Response(e);
|
.catch((err) => console.error(err));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response.redirect("https://michaelpivato.dev");
|
return Response.redirect("https://michaelpivato.dev");
|
||||||
|
|||||||
Reference in New Issue
Block a user