Fetches the page model data.
Axios satisfies this type directly and can be passed as-is:
import axios from 'axios';
initialize({ httpClient: axios, ... });
When using the native fetch API, a thin wrapper is required because fetch
takes (url, init) as separate arguments, returns Response instead of
{ data: T }, and only accepts string header values:
import { HttpClient } from '@bloomreach/spa-sdk';
const httpClient: HttpClient<PageModel> = async ({ method, url, headers, data }) => {
const response = await fetch(url, {
method,
headers: headers as Record<string, string>,
body: data !== undefined ? JSON.stringify(data) : undefined,
});
return { data: await response.json() };
};
Configuration of an HTTP client call.
Optional: the data to send with the HTTP request. Will only be provided when the 'method' is 'post'.
Optional: the headers to send with the HTTP request.
HTTP request method.
The URL to send the HTTP request to.
Map of HTTP headers.
Meta-data following before a page component.
Meta-data following after a page component.
A blocked container with blocked items.
A blocked container with inline items.
A container item without mapping.
A container without surrounding markup.
An ordered list container.
An unordered list container.
Link to a page outside the current application.
Link to a page inside the current application.
Link to a CMS resource.
A manage content button.
A manage menu button.
Destroys the integration with the SPA page.
Extracts query parameters from URL and returns URL object that contains URL path and extracted parameters
The URL of the page.
Parameters to extract.
Returns the content of this component.
The component that references the content
The page that contains the content
Resolves an array of references (e.g. a pagination item list) to documents in one call, instead of requiring the caller to map over the references and resolve/guard each one individually. References that cannot be resolved to a document are omitted from the result.
The page that contains the documents.
The document references to resolve.
The resolved documents, in the same order as the references.
Resolves an image reference to a concrete image in one call, instead of requiring the caller to look up the image set and then pick a variant.
The page that contains the image.
A reference to the image set, or undefined if the field is not set.
The variant name. When omitted, the original image is returned.
The resolved image, or undefined if the reference is missing or cannot be resolved.
Initializes the page model.
Configuration of the SPA integration with brXM.
Preloaded page model.
Initializes the page model.
Configuration of the SPA integration with brXM.
Checks whether a value is a page component.
The value to check.
Checks whether a value is a page container.
The value to check.
Checks whether a value is a page container item.
The value to check.
Checks whether a value is a document.
The value to check.
Checks whether a value is an image set.
The value to check.
Checks whether a value is a link.
The value to check.
Checks whether a value is a menu.
The value to check.
Checks whether a value is a meta-data object.
The value to check.
Checks whether a value is a meta-data comment.
The value to check.
Checks whether a value is a page.
The value to check.
Checks whether a value is a pagination.
The value to check.
Checks whether a value is a reference.
The value to check.
Main entry point of the spa-sdk library.