Re-add wait on email to send as otherwise cloudflare triggers a disconnect and stops the worker
All checks were successful
release / Publish to Cloudflare Pages (push) Successful in 1m8s
All checks were successful
release / Publish to Cloudflare Pages (push) Successful in 1m8s
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.
|
||||
if ((fullName || email) && message) {
|
||||
// Don't await response so the client doesn't have to wait for email to send as it
|
||||
// feels unresponsive
|
||||
context.env.SERVICE.sendEmail({
|
||||
fullName,
|
||||
organisation,
|
||||
email,
|
||||
mobile,
|
||||
message,
|
||||
})
|
||||
.then(() => console.log("Sent email"))
|
||||
.catch((err) => console.error(err));
|
||||
try {
|
||||
await context.env.SERVICE.sendEmail({
|
||||
fullName,
|
||||
organisation,
|
||||
email,
|
||||
mobile,
|
||||
message,
|
||||
});
|
||||
} catch (e) {
|
||||
return new Response(e);
|
||||
}
|
||||
}
|
||||
|
||||
return Response.redirect("https://michaelpivato.dev");
|
||||
|
||||
Reference in New Issue
Block a user