@hateoas-ts/resource - v1.4.3
    Preparing search index...

    Type Alias RequestOptions<T>

    Configuration options for HTTP requests.

    RequestOptions provides flexible ways to specify request body and headers for Resource HTTP methods (GET, POST, PUT, PATCH, DELETE).

    // Simple JSON data
    await resource.post({ data: { name: 'John' } });

    // Custom serialization
    await resource.post({
    serializeBody: () => customSerialize(data),
    getContentHeaders: () => ({ 'Content-Type': 'application/xml' })
    });
    type RequestOptions<T = SafeAny> = {
        data?: T;
        getContentHeaders?: () => HttpHeaders | Headers;
        headers?: HttpHeaders | Headers;
        serializeBody?: () => string | Buffer | Blob;
    }

    Type Parameters

    • T = SafeAny

      The type of the data payload

    Index

    Properties

    data?: T

    The request body data.

    If not a string or Buffer, the data will be JSON-encoded automatically. Ignored if serializeBody is provided.

    getContentHeaders?: () => HttpHeaders | Headers

    Function returning content-related headers.

    Takes precedence over the headers property.

    Type Declaration

    headers?: HttpHeaders | Headers

    HTTP headers for the request.

    Used as fallback when getContentHeaders is not provided.

    serializeBody?: () => string | Buffer | Blob

    Custom body serialization function.

    When provided, this function is called to serialize the request body. Takes precedence over the data property.

    Type Declaration

      • (): string | Buffer | Blob
      • Returns string | Buffer | Blob

        Serialized body as string, Buffer, or Blob