Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "frontend-packages/cookie-consent-web-client/src/api/consent"

Index

Functions

Functions

consent

  • consent(...args: Parameters<typeof consentSync>): Promise<void>
  • window.consentApi.consent: Check if a given technical information (e.g. HTTP Cookie, LocalStorage, ...) has a consent:

    • When a technical information exists in defined cookies, the Promise is only resolved after given consent
    • When no technical information exists, the Promise is immediate resolved

    Example (ES5):

    (window.consentApi && window.consentApi.consent("http", "_twitter_sess", ".twitter.com") || Promise.resolve()).then(function() {
        console.log("Consent for Twitter embed given, do something...!");
    });
    

    Example (ES6, Babel, TS):

    (window.consentApi?.consent("http", "_twitter_sess", ".twitter.com") || Promise.resolve()).then(() => {
        console.log("Consent for Twitter embed given, do something...!");
    });
    

    Since 2.3.0: You can also check for consent by cookie ID (ID in wp_posts, post id):

    window.consentApi.consent(15)
    

    Parameters

    Returns Promise<void>

Generated using TypeDoc