Documentation
    Preparing search index...

    Interface IHttpConnection

    HTTP connection configuration for remote server communication.

    IHttpConnection defines connection settings required to communicate with remote HTTP servers. This interface is primarily used by @nestia/fetcher and generated SDK functions to establish HTTP connections.

    The host property specifies the base URL of the target server, while headers allows passing custom HTTP headers with each request. For fine-grained control over fetch behavior, use options to configure caching, CORS, credentials, and other fetch API settings.

    In Node.js versions prior to 20 (which lack native fetch), provide a polyfill like node-fetch via the fetch property.

    Jeongho Nam - https://github.com/samchon

    Seungjun We - https://github.com/SeungjunWe

    interface IHttpConnection {
        fetch?: (
            input: RequestInfo | URL,
            init?: RequestInit,
        ) => Promise<Response>;
        headers?: Record<string, HeaderValue>;
        host: string;
        options?: IOptions;
    }
    Index

    Properties

    fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>

    Custom fetch function implementation.

    For Node.js versions before 20 that lack native fetch support, provide a polyfill such as node-fetch. This allows the same connection configuration to work across all Node.js versions.

    Type Declaration

      • (input: RequestInfo | URL, init?: RequestInit): Promise<Response>
      • Parameters

        • input: RequestInfo | URL
        • Optionalinit: RequestInit

        Returns Promise<Response>

    import fetch from "node-fetch";

    const connection: IHttpConnection = {
    host: "https://api.example.com",
    fetch: fetch as any,
    };
    headers?: Record<string, HeaderValue>

    Custom HTTP headers to send with every request.

    Common use cases include authentication tokens, API keys, and content negotiation headers. Values can be primitives or arrays.

    host: string

    Base URL of the remote HTTP server.

    Must include protocol (http:// or https://) and may include port. Example: "https://api.example.com" or "http://localhost:3000".

    options?: IOptions

    Additional fetch API options.

    Configure caching, CORS mode, credentials handling, and other fetch-specific behaviors. These options are passed directly to the underlying fetch call.