Skip to main content

@pantheon-systems/drupal-kit

Classes

Functions

defaultFetch

defaultFetch(apiUrl, requestInit?, res?, cacheControl?): Promise<Response>

fetch data from a JSON:API endpoint, bubbling up surrogate keys if possible

Parameters

NameTypeDefault valueDescription
apiUrlRequestInfoundefinedthe api url for the JSON:API endpoint
requestInitRequestInit{}fetch initialization object
res?boolean | ServerResponse<IncomingMessage>undefinedresponse object
cacheControlstringdefaultCacheControlValueoptional value to override cache control header, defaults to 'public, s-maxage=600'

Returns

Promise<Response>

a promise containing the data for the JSON:API response

Defined in

packages/drupal-kit/src/lib/defaultFetch.ts:16


fetchJsonapiEndpoint

fetchJsonapiEndpoint(apiUrl, requestInit?, onError?, res?, fetch?): Promise<void | Response>

fetch data from a JSON:API endpoint

Parameters

NameTypeDescription
apiUrlstringthe api url for the JSON:API endpoint
requestInit?Objectfetch initialization object
onError?(err: Error) => voidcustom error handler defaults to throw error
res?boolean | ServerResponse<IncomingMessage>response object
fetch?fetchAdapterfetch compatible function

Returns

Promise<void | Response>

a promise containing the data for the JSON:API response

Defined in

node_modules/.pnpm/@[email protected]_react@18.2.0/node_modules/@gdwc/drupal-state/dist/src/fetch/fetchJsonapiEndpoint.d.ts:18


getDrupalSearchResults

getDrupalSearchResults(«destructured»): Promise<TJsonApiBody>

Helper function to query the Drupal Search API.

Parameters

NameType
«destructured»GetDrupalSearchResultsParams

Returns

Promise<TJsonApiBody>

An array of search results matching the query.

See

https://www.drupal.org/docs/contributed-modules/search-api for more information about the Drupal Search API.

Defined in

packages/drupal-kit/src/lib/getDrupalSearchResults.ts:23


setSurrogateKeyHeader

setSurrogateKeyHeader(keys, res): string | void

Adds an aggregated list of surrogate keys in the working response.

Parameters

NameTypeDescription
keysnull | stringValue for surrogate-key header in API response.
resServerResponse<IncomingMessage>The active http.ServerResponse object.

Returns

string | void

The current known unique set of surrogate keys.

Defined in

packages/cms-kit/dist/lib/setSurrogateKeyHeader.d.ts:9


translatePath

translatePath(apiUrl, path, requestInit?, res?, fetch?, onError?): Promise<void | TJsonApiBody>

helper function to make it easier to resolve a path to an entity ID

Parameters

NameTypeDescription
apiUrlstringthe api url for the JON:API endpoint
pathstringthe path to the node
requestInit?Objectfetch initialization object
res?boolean | ServerResponse<IncomingMessage>response object
fetch?fetchAdapterfetch compatible function
onError?(err: Error) => void-

Returns

Promise<void | TJsonApiBody>

a promise containing the data for the JSON:API response

Defined in

node_modules/.pnpm/@[email protected]_react@18.2.0/node_modules/@gdwc/drupal-state/dist/src/fetch/translatePath.d.ts:17