Skip to content

saveConsents(): void

The saveConsents method allows to save the current granted consents status to the local storage.

Input parameters

none

Returned value

A returned value has a type of void as this method does not return anything.

Event Bus events

This API method dispatches the following events with the Event Bus:

Example

In this example we make a customerPrivacyApi call to grant a given array of consent names and then save them to a local storage.

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

    customerPrivacyApi.grantConsents(['marketingConsent', 'analyticsConsent']);
    customerPrivacyApi.saveConsents();
});

Customer Privacy API methods reference