[]previous and next page

formToObject

Converts form data to a plain object.

Converts form data to a plain object. Repeated fields become arrays, files stay File objects, and the keys __proto__, constructor and prototype are dropped.

Import#

ts
import { formToObject } from "@shadow-js/dusk/server";

Signature#

ts
function formToObject(data: FormData | URLSearchParams): Record<string, unknown>

Parameters#

Name Description
data A FormData or URLSearchParams.

Returns#

A null-prototype object.

Throws#

  • HttpError 400 when a field name holds U+FFFD (the sign of bytes that were not UTF-8).

Examples#

ts
const fields = formToObject(await request.formData());