Skip to content

Commit

Permalink
chore: add env and ctx params to fetch in javascript example te…
Browse files Browse the repository at this point in the history
…mplate (#1943)

Just like in the typescript templates, and the javascript template for scheduled workers, we include `env` and `ctx` as parameters to the `fetch` export. This makes it clearer where environment variables live.
  • Loading branch information
cameron-robey committed Sep 28, 2022
1 parent 5854cb6 commit 58a430f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changeset/brave-ties-obey.md
@@ -0,0 +1,7 @@
---
"wrangler": patch
---

chore: add `env` and `ctx` params to `fetch` in javascript example template

Just like in the typescript templates, and the javascript template for scheduled workers, we include `env` and `ctx` as parameters to the `fetch` export. This makes it clearer where environment variables live.
2 changes: 1 addition & 1 deletion packages/wrangler/templates/new-worker.js
Expand Up @@ -9,7 +9,7 @@
*/

export default {
async fetch(request) {
async fetch(request, env, ctx) {
return new Response("Hello World!");
},
};

0 comments on commit 58a430f

Please sign in to comment.