You are reading the documentation for v7.x and earlier, which is no longer the latest version. Switch to v8.x
getConsentTemplates
Method fetching a list of all consent templates from SAP Commerce Cloud.
This method sends a POST request to the getAllConsents endpoint of the Alokai Middleware. In turn, it receives data from the getConsentTemplates endpoint exposed by the SAP OCC API Consents Controller.
When vsf-sap-token cookie is present in the browser, this method will fetch consent templates for the current user. In case there is no cookie, it will fetch them for an anonymous user.
You might also want to see the getConsentTemplate method.
Signature
export declare function getConsentTemplates<Res extends ConsentTemplateList = ConsentTemplateList,
Props extends BaseProps & BaseUserId = BaseProps & BaseUserId>(
props?: Props,
options?: MethodOptions
): Promise<Res>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
props | Optional | 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 List.
Referenced Types
Examples
Fetching a list of consent templates.
import { sdk } from '~/sdk';
const { consentTemplates } = await sdk.commerce.getConsentTemplates();Fetching a list of consent templates and selecting response fields.
import { sdk } from '~/sdk';
const { consentTemplates } = await sdk.commerce.getConsentTemplates({
fields: 'consentTemplates(id,name)'
});