Alokai
You are reading the documentation for v7.x and earlier, which is no longer the latest version. Switch to v8.x

getConsentTemplate

Get single consent template from SAP Commerce Cloud.

This method receives data from the getConsentTemplate endpoint exposed by the SAP OCC API Consents Controller.

When vsf-sap-token cookie is present in the request, 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.

Signature

export declare function getConsentTemplate(
	context: SapccIntegrationContext,
	props: GetConsentTemplateProps
): Promise<ConsentTemplate>;

Parameters

NameRequiredTypeDescription
contextRequiredSapccIntegrationContext
propsRequiredGetConsentTemplatePropsParameter object which can be used with this method. Refer to its type definition to learn about possible properties.

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'
});

On this page