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

giveConsent

Method giving consent on behalf of an authenticated user in SAP Commerce Cloud.

This method sends a POST request to the giveConsent endpoint of the Alokai Middleware. In turn, it exchanges data with the doGiveConsent endpoint exposed by the SAP OCC API Consents Controller.

The method gives consent on behalf of an authenticated user based on the vsf-sap-token cookie (which is assigned to that customer). The cookie must be present in the browser for the method to work properly.

You might also want to see the removeConsent method.

Signature

export declare function giveConsent<Res extends ConsentTemplate = ConsentTemplate,
	Props extends GiveConsentProps = GiveConsentProps>(
	props: Props,
	options?: MethodOptions
): Promise<Res>;

Parameters

NameRequiredTypeDescription
propsRequiredPropsParameter object which can be used with this method. Refer to its type definition to learn about possible properties.
optionsOptionalMethodOptionsOptions 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

Giving consent.

import { sdk } from '~/sdk';

const givenConsent = await sdk.commerce.giveConsent({
  consentTemplateId: 'MARKETING_NEWSLETTER',
  consentTemplateVersion: 0
});

On this page