Examples of making fetch requests from within your Worker script including generating JSON post requests then reading in the resulting response body, aggregating multiple requests into one response, and following/catching redirects.
Uses TypeScript types from: udacity/cloudflare-typescript-workers
. Example Github Repository Template with Jest Tests: udacity/cloudflare-typescript-worker-template
.
index.ts
is the content of the Workers script.
Live Demos are hosted on workers-tooling.cf/demos/fetch
:
Demo JSON | Demo HTML
To generate using wrangler
wrangler generate myApp https://github.com/13rac1/cloudflare-ts-worker-template-fetch
Run npm run build
to build with TypeScript
To deploy using serverless add a serverless.yml
file.