Alokai

get

Method fetching a single content entry by its url or id.

This method sends a GET request to the get 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.

A urlPath can be a simple string or a path such as "home-page/feature-banner". This makes it simpler to write your integration code and allows users more control over where items of content are delivered.

The content body will match the format defined by your content model.

Signature

export declare function get(
	modelName: string,
	builderOptions?: GetContentOptions & {
    req?: IncomingMessage;
    res?: ServerResponse;
    apiKey?: string;
    authToken?: string;
},
	options?: MethodOptions
): BehaviorSubject<any,
	any>;

Parameters

NameRequiredTypeDescription
modelNameRequiredstringThe model name for the component, section or page that is fetched.
builderOptionsRequiredGetContentOptions & { req?: IncomingMessage; res?: ServerResponse; apiKey?: string; authToken?: string; }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.
optionsRequiredMethodOptionsOptions that can be passed to additionally configure the request or customize the logic in a plugin.

Returns

BehaviorSubject<any, any>

Referenced Types

Examples

Fetching a single content entry by its delivery key. Notice how we are using the type parameter to specify the response interface.

import { sdk } from '~/sdk.config.ts';

const entry = await sdk.builder.get(
 'page',
 {
   userAttributes: {
     urlPath: '/home'
   }
});

On this page