Skip to content

Instantly share code, notes, and snippets.

View justinnoel's full-sized avatar

Justin Noel justinnoel

View GitHub Profile
@justinnoel
justinnoel / get-form-data.js
Last active November 12, 2021 11:46
Extract Form Submission Details for a Cloudflare Worker.
async function getFormData(request) {
const { headers } = request;
const contentType = headers.get("content-type") || "";
if (contentType.includes("application/json")) {
return await request.json();
}
if (contentType.includes("form")) {
const formData = await request.formData();