ConstMost developers won't need to use this directly. The standard service functions
(like geocode, search, calculateRoute) are sufficient for typical use cases.
Only use customization when you need to modify the internal service behavior.
Each service exposes:
import { isProxyCredentialsMode, mergeFromGlobal } from '@tomtom-org/maps-sdk/core';
import { customizeService } from '@tomtom-org/maps-sdk/services';
const { buildGeocodingRequest, parseGeocodingResponse } = customizeService.geocode;
// Request builders expect the global configuration to be merged in already
const config = mergeFromGlobal({ query: 'Amsterdam' });
const { url, headers } = buildGeocodingRequest(config);
// Send the request yourself, then parse the raw API payload. The credential travels in
// `headers` — pass them on, or the request is unauthenticated. With a credentials proxy
// (no `apiKey`, custom `commonBaseURL`) the proxy's session cookie has to travel instead,
// so send `credentials: 'include'` the way the SDK's own fetch does.
const apiResponse = await fetch(url, {
headers,
...(isProxyCredentialsMode(config) && { credentials: 'include' }),
});
const places = parseGeocodingResponse(await apiResponse.json());
Access to service implementation components for advanced customization.
This object provides low-level access to the internal components of each service, allowing developers to customize request building, response parsing, and other aspects of service behavior. This is useful for advanced use cases like: