Prerequisites

To get the most out of this guide, you’ll need to:

1. Create a Cloudflare Workers project

pnpm create cloudflare@latest formizee-workers-example

2. Update the main script

Update the file under src/index.ts with the next code, then update the Endpoint URL.

index.ts
const ENDPOINT_URL = "https://api.formizee.com/v1/f/enp_123456";

export default {
	async fetch(
		_request: Request,
		_env: Env,
		_ctx: ExecutionContext,
	): Promise<Response> {
		const res = await fetch(ENDPOINT_URL, {
			method: "POST",
			headers: {
				"Content-Type": "application/json",
			},
			body: JSON.stringify({
				name: "example",
				email: "[email protected]",
			}),
		});
		const data = await res.json();
		return new Response(JSON.stringify(data), {
			headers: {
				"Content-Type": "application/json",
			},
		});
	},
};

3. Run in local

pnpm run dev

4. Try it yourself

Formizee Cloudflare Workers Example

See the full source code