getContent
Method fetching a single content entry by its ID.
This method sends a GET request to the getContent endpoint of the Vue Storefront API Middleware.
If the content is not found, the promise will reject with an error. If the content is found the promise will resolve with a parsed version of the content with all dependencies. The content body will match the format defined by your content type, however keep in mind that if you have evolved your content type some published content may still be in the older format.
Signature
export declare function getContent(
modelName: string,
builderOptions?: GetContentOptions,
options?: MethodOptions
): BehaviorSubject<BuilderContent[],
any>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
modelName | Required | string | The model name for the component, section or page that is fetched. |
builderOptions | Required | GetContentOptions | Object containing all optional properties to fetch content e.g.: userAttributes object which allows to specify urlPath of the content or queryString and many more. |
options | Required | MethodOptions | Options that can be passed to additionally configure the request or customize the logic in a plugin. |
Referenced Types
GetContentOptions- MethodOptions
BehaviorSubjectBuilderContent
Examples
Fetching content entries by its model name and entry id.
import { sdk } from '~/sdk.config.ts';
const { data } = await sdk.builder.getContent(
'page',
{
options: {
noTargeting: true,
},
entry: id,
enrich: true,
}
);