Skip to main content
Module

x/cav/mod.ts>serializeBody

A server framework for Deno
Go to Latest
function serializeBody
Re-export
import { serializeBody } from "https://deno.land/x/cav@0.0.21/mod.ts";

Serializes a value into a type that is compatible with a Response BodyInit, making it easy to serialize values for sending to an external host/client via HTTP. If a provided value is already compatible with BodyInit, it will be returned with an appropriate mime type, skipping the serialization process. During serialization, this function extends the default supported types to include Blobs and Files. If a Blob is encountered during serialization, the resulting body will be a multipart FormData that encodes the shape of the input as well as the blobs that were encountered. Otherwise, a regular JSON string will be returned. Blobs and Files can be placed anywhere on the input value, even if they are nested.

Parameters

value: unknown
optional
serializers: Serializers

Returns

{ body: BodyInit; mime: string; }