You are reading the documentation for v7.x and earlier, which is no longer the latest version. Switch to v8.x
getConsentTemplate
Method fetching a single consent template from SAP Commerce Cloud.
This method sends a POST request to the getConsent endpoint of the Alokai Middleware. In turn, it receives data from the getConsentTemplate endpoint exposed by the SAP OCC API Consents Controller.
When vsf-sap-token cookie is present in the browser, this method will fetch a consent template with given id for the current user. In case there is no cookie, it will fetch it for an anonymous user.
You might also want to see the getConsentTemplates method.
Signature
export declare function getConsentTemplate<Res extends ConsentTemplate = ConsentTemplate,
Props extends GetConsentTemplateProps = GetConsentTemplateProps>(
props: Props,
options?: MethodOptions
): Promise<Res>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
props | Required | Props | Parameter object which can be used with this method. Refer to its type definition to learn about possible properties. |
options | Optional | MethodOptions | Options that can be passed to additionally configure the request or customize the logic in a plugin. |
Returns
Returns a representation of a Consent Template.
Referenced Types
Examples
Fetching a consent template.
import { sdk } from '~/sdk';
const consentTemplate = await sdk.commerce.getConsentTemplate({
consentTemplateId: 'MARKETING_NEWSLETTER'
});Fetching a consent template and selecting response fields.
import { sdk } from '~/sdk';
const consentTemplate = await sdk.commerce.getConsentTemplate({
consentTemplateId: 'MARKETING_NEWSLETTER',
fields: 'id,name,description'
});