Skip to content

onFunctionalConsentGranted(callback: () => void): void

The onFunctionalConsentGranted is used to provide a callback which will be called when the user grants the functionalConsent.

Input parameters

callback

callback is a mandatory parameter of the () => void type which represents a function that will run once functional consents are granted by the user.

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 fire a callback whenever functional consents are granted by the user.

useStorefront((storefront) => {
    const customerPrivacyApi = await storefront.getApi('customerPrivacyApi');

    customerPrivacyApi.onFunctionalConsentGranted(() => {
        console.log('Functional consent has been granted!');
    });
});

Customer Privacy API methods reference