This is the documentation of version 0.62.3. 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> & {
        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

    • 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)]).

      Keep only the latest search with createLatestRequest:

      const latestSearch = createLatestRequest();
      const search = await latestSearch.run((signal) => discoverPlaces({ query, signal }));
      if (search.current) showResults(search.value);

      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 request validation, cancellation, and lifecycle event listeners.