grantConsents(consents: TConsentName[]): void¶
The grantConsents
method allows to grant a given array of consents.
Input parameters¶
consents¶
consents
is a mandatory parameter of the TConsentName[]
type which represents an array of consents to grant. To see all the possible consent names see the Consent names section of the Customer Privacy API.
Returned value¶
A returned value has a type of void
as this method does not return anything.
Example¶
In this example we make a customerPrivacyApi
call to grant a given array of consent names.
useStorefront((storefront) => {
const customerPrivacyApi = await storefront.getApi('customerPrivacyApi');
customerPrivacyApi.grantConsents(['marketingConsent', 'analyticsConsent']);
});
Customer Privacy API methods reference¶
- getGrantedNames
- onAnalyticsConsentGranted
- onMarketingConsentGranted
- onFunctionalConsentGranted
- onPlatformConsentGranted
- showConsentsModal
- showAdvancedConsentsModal
- withdrawConsents
- saveConsents
- isCookieInformationEnabled