HttpRequestShape
Request shape an HTTP builder returns: path, query, headers, and body.
@defjs/core · Type
Signature
type HttpRequestShape<P extends string, M extends string> = { body?: Uppercase<M> extends "GET" | "HEAD" ? never : BodyValue; headers?: HeadersInit | FlatRecord; path?: PathValue<P>; query?: URLSearchParams | QueryRecord; };
P is the endpoint path and M its method. GET and HEAD cannot return a
body. BodyValue is a wire value Fetch sends as is (string, Blob,
ArrayBuffer, a typed array or DataView, FormData, URLSearchParams,
ReadableStream<Uint8Array>) or JSON data (number, boolean, bigint,
Date, null, an array, or an object type with string keys); an interface
value or class instance needs { ...value }. path values must be scalars.
A header value may be a scalar or an array of scalars, and HeadersInit is
accepted. query may nest, and a nested object needs withQuerySerializer
at runtime. FlatRecord, QueryRecord, PathValue, and BodyValue are
internal helper types.
Members
Prop
Type
body? (Uppercase<M> extends "GET" | "HEAD" ? never : BodyValue) | undefinedRequest body. Not allowed for GET or HEAD. Other methods send a native body or encoded JSON, depending on the value.
headers? FlatRecord | HeadersInit | undefinedHeadersInit or a flat record of scalars or scalar arrays. Put cross-request policies on the Client.
path? PathValue<P> | undefinedExplicit values for path placeholders. Anonymous objects use template keys; typed objects apply their struct aliases.
query? QueryRecord | URLSearchParams | undefinedURLSearchParams passes through unchanged; objects are encoded first. Configure the Client's query serializer for nested query values.