Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/live/clients/formdata.ts>propsToFormData

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