This is the documentation of version 0.55.1. Go to the latest version, 1.0.0-rc.5.
TomTom Maps for JavaScript
    Preparing search index...

    Type Alias CommonServiceParams<ApiRequest, ApiResponse>

    CommonServiceParams: Partial<GlobalConfig> & {
        customServiceBaseURL?: string;
        onAPIRequest?: (apiRequest: ApiRequest) => void;
        onAPIResponse?: (apiRequest: ApiRequest, apiResponse: ApiResponse) => void;
        signal?: AbortSignal;
        validateRequest?: boolean;
    }

    Common parameters shared across all service calls.

    Type Parameters

    • ApiRequest = any

      The type of the API request object

    • ApiResponse = any

      The type of the API response object

    Type Declaration

    • OptionalcustomServiceBaseURL?: string

      Custom base URL for the service endpoint.

      Should contain the URL up to the part that changes per service call.

      customServiceBaseURL: 'https://api.tomtom.com/search/10/reverseGeocode/'
      

      undefined (uses default service URL)

    • OptionalonAPIRequest?: (apiRequest: ApiRequest) => void

      Callback invoked immediately before sending the request to the API.

      Useful for tracking, logging, or debugging API requests before they are sent to the server.

    • OptionalonAPIResponse?: (apiRequest: ApiRequest, apiResponse: ApiResponse) => void

      Callback invoked when the raw response is received from the API.

      Called as soon as the API response is received, before parsing. The request object is the same reference as provided to onAPIRequest. Useful for tracking, logging, or debugging successful API request-response pairs.

    • Optionalsignal?: AbortSignal

      An AbortSignal used to cancel the request.

      Aborting rejects the call with an SDKAbortError (its name is 'AbortError') and cancels the underlying HTTP request, including while the SDK is waiting to retry a rate-limited (429) response. Aborting a call that already completed has no effect.

      Compose signals to add a deadline: AbortSignal.any([mine, AbortSignal.timeout(5000)]).

      Cancel the previous search whenever a new one starts:

      let controller: AbortController | undefined;

      const searchForQuery = async (query: string) => {
      controller?.abort();
      controller = new AbortController();
      try {
      return await search({ query, signal: controller.signal });
      } catch (error) {
      if (error instanceof SDKAbortError) return;
      throw error;
      }
      };

      undefined (the request cannot be cancelled)

    • OptionalvalidateRequest?: boolean

      Controls whether input request schema validation is performed.

      When enabled, the SDK validates request parameters against the expected schema before sending the request to the API. Set to false to skip validation.

      true

    This type extends the global configuration and provides additional service-specific options such as custom base URLs, request validation, and lifecycle event listeners.