Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/blocks/clients/formdata.ts>propsToFormData

Git-based Visual CMS for Deno, </> htmx and Tailwind apps. Deploy on any Deno-compatible host.
Go to Latest
function propsToFormData
import { propsToFormData } from "https://deno.land/x/blocks@1.101.14/clients/formdata.ts";

Convert a javascript object to a FormData instance.

Usage:

const formData = propsToFormData({ foo: "bar", baz: [1, 2, 3] });
formData.get("foo"); // "bar"
formData.get("baz.0"); // 1
formData.get("baz.1"); // 2
formData.get("baz.2"); // 3

Parameters

props: unknown

Can be any valid serializable javascript object. Arrays as root will throw an error, since we cannot represent them as multipart.

Returns

FormData instance with the given props.