FuncType - v1.21.0
    Preparing search index...

    Type Alias Encoder<A>

    Encoder: (value: A) => Serialization.JSONValue

    An Encoder<A> turns a typed value into the JSON that goes on the wire — the request-side counterpart of Decoder. Any function with this shape is an encoder.

    Pass one as encode on an Http request when flatten can't express the wire shape you need: custom date formats, snake_case keys, stripping fields.

    Type Parameters

    • A

    Type Declaration

    const encodeUser: Encoder<User> = (u) => ({ user_name: u.name, created_at: u.createdAt.toISOString() })
    Http.post("/users", { body: user, encode: encodeUser })