A year ago Cloudflare’s worker start example code was:
addEventListener("fetch", (event) => {
event.respondWith(
handleRequest(event.request).catch(
(err) => new Response(err.stack, { status: 500 })
)
);
});
async function handleRequest(request) {
return new Response("Hello world");
}
Now it’s
export default {
async fetch(request, env) {
return new Response("Hello world")
}
}
Is there any reason why the second method is preferred over the first?