DecoupledRouterClient
Decoupled Router Client class provides functionality specific to the decoupled-router module.
See
- ApiClientOptions
- BaseUrl
Extends
ApiClient
Constructors
new DecoupledRouterClient()
Creates a new instance of the DecoupledRouterClient.
Parameters
• baseUrl: string
The base URL of the API. BaseUrl
• options?: ApiClientOptions
(Optional) Additional options for configuring the API client. ApiClientOptions
Returns
Overrides
ApiClient.constructor
Source
decoupled-router-client/src/DecoupledRouterClient.ts:23
Properties
#private
Inherited from
ApiClient.#private
Source
api-client/dist/index.d.mts:208
apiPrefix
Inherited from
ApiClient.apiPrefix
Source
api-client/dist/index.d.mts:216
authentication
ApiClientOptions.authentication
Inherited from
ApiClient.authentication
Source
api-client/dist/index.d.mts:224
baseUrl
BaseUrl
Inherited from
ApiClient.baseUrl
Source
api-client/dist/index.d.mts:212
cache
Inherited from
ApiClient.cache
Source
api-client/dist/index.d.mts:232
customFetch
Inherited from
ApiClient.customFetch
Source
api-client/dist/index.d.mts:220
debug
Inherited from
ApiClient.debug
Source
api-client/dist/index.d.mts:244
defaultLocale
ApiClientOptions.defaultLocale
Inherited from
ApiClient.defaultLocale
Source
api-client/dist/index.d.mts:228
logger
Inherited from
ApiClient.logger
Source
api-client/dist/index.d.mts:240
serializer
Inherited from
ApiClient.serializer
Source
api-client/dist/index.d.mts:236
Methods
addAuthorizationHeader()
Adds an authorization header to the provided RequestInit options if authentication of type “Basic” is configured. If the authentication type is “OAuth”, it will fetch a new access token or use the stored access token if it exists and is still valid. if the authentication type is “Custom”, it will use the provided value.
Parameters
• options: undefined
| RequestInit
The RequestInit options to which the authorization header should be added.
Returns
Promise
<RequestInit
>
The updated RequestInit options with the authorization header, if applicable.
Inherited from
ApiClient.addAuthorizationHeader
Source
api-client/dist/index.d.mts:274
createURL()
Generates an endpoint URL based on the provided parameters.
Parameters
• __namedParameters
• __namedParameters.localeSegment?: string
• __namedParameters.path: string
Returns
string
The endpoint URL as a string.
Params
params - The parameters to use for creating the URL.
Source
decoupled-router-client/src/DecoupledRouterClient.ts:90
fetch()
Uses customFetch if it is set, otherwise uses the default fetch
Parameters
• input: RequestInfo
| URL
RequestInfo
• init?: RequestInit
RequestInit
Returns
Promise
<FetchReturn
>
a response wrapped in a promise
Inherited from
ApiClient.fetch
Source
api-client/dist/index.d.mts:257
getAccessToken()
Fetch the OAuth token from the BaseUrl
Parameters
• __namedParameters: OAuthCredentials
Returns
Promise
<OAuthTokenResponse
>
Inherited from
ApiClient.getAccessToken
Params
params - The credentials for getting an OAuth token. OAuthCredentials
Source
api-client/dist/index.d.mts:262
getCachedResponse()
Retrieves a cached response from the cache.
Type parameters
• T
Parameters
• cacheKey: string
The cache key to use for retrieving the cached response.
Returns
Promise
<null
| NonNullable
<Awaited
<T
>>>
A promise wrapping the cached response as a generic type.
Inherited from
ApiClient.getCachedResponse
Source
api-client/dist/index.d.mts:286
log()
Calls the appropriate logger method based on level
Parameters
• level: LogLevels
level based on npm log levels
• message: string
the message to log
Returns
void
Inherited from
ApiClient.log
Source
api-client/dist/index.d.mts:280
translatePath()
Translates a path in the consuming application to a Drupal entity.
Parameters
• path: string
the path to translate
• options?: GetOptions
Returns
Promise
<DecoupledRouterResponse
| RawDecoupledRouterResponse
>
A Promise that resolves to the JSON data provided by the router.
Source
decoupled-router-client/src/DecoupledRouterClient.ts:34
createCacheKey()
Generates a cache key based on the provided parameters.
Parameters
• __namedParameters
• __namedParameters.cacheKey?: string
• __namedParameters.localeSegment?: string
• __namedParameters.path?: string
Returns
string
The generated cache key as a string.
Params
params - The parameters to use for generating the cache key.
Example
Source
decoupled-router-client/src/DecoupledRouterClient.ts:110