Skip to main content

DenchCreateBuilder

Summary

The builder type used to configure POST and PUT requests. It provides common builder APIs, runner APIs, and request body configuration APIs.

Type Definition

interface DenchCreateBuilder<T>
extends DenchBuilder<T, DenchCreateBuilder<T>>,
DenchRunner<T> {
sendJson: (data?: unknown) => DenchCreateBuilder<T>;
sendForm: (data?: FormData) => DenchCreateBuilder<T>;
sendBlob: (data?: Blob) => DenchCreateBuilder<T>;
sendUrlEncoded: (data?: DenchURLSearchParams) => DenchCreateBuilder<T>;
sendRaw: (data?: BodyInit) => DenchCreateBuilder<T>;
api: <P = T>(api: string) => DenchCreateBuilder<P>;
}

Generics

GenericDescription
TThe JSON response type returned by toJson().
PThe JSON response type assigned to the new builder by api<P>(). Defaults to T.

Properties

PropertyTypeRequiredDescription
sendJson(data?: unknown) => DenchCreateBuilder<T>YesSets a JSON body and Content-Type header.
sendForm(data?: FormData) => DenchCreateBuilder<T>YesSets a FormData body.
sendBlob(data?: Blob) => DenchCreateBuilder<T>YesSets a Blob body.
sendUrlEncoded(data?: DenchURLSearchParams) => DenchCreateBuilder<T>YesSets a URL-encoded body.
sendRaw(data?: BodyInit) => DenchCreateBuilder<T>YesSets a raw BodyInit body.
api<P = T>(api: string) => DenchCreateBuilder<P>YesChanges the API path and response type.

It also inherits every property from DenchBuilder<T, DenchCreateBuilder<T>> and DenchRunner<T>.

Used By

  • Return type of DenchInterface.post<T>().
  • Return type of DenchInterface.put<T>().
  • Used by the body configuration and runner APIs for POST and PUT requests.
import type { DenchCreateBuilder } from 'dench-fetch';