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

x/deco/clients/formdata.ts>propsToFormData

Git-based Visual CMS for Deno, </> htmx and Tailwind apps. Deploy on any Deno-compatible host.
Latest
function propsToFormData
import { propsToFormData } from "https://deno.land/x/deco@1.107.0/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.