ngx-cookieconsent icon indicating copy to clipboard operation
ngx-cookieconsent copied to clipboard

[Bug] getStatus() returns a value that is helpless in deciding about the consent status

Open xOctave opened this issue 1 year ago • 1 comments

Ngx-CookieConsent Version

6.0.0

CookieConsent Version

3.0.0

Angular CLI (or Nx CLI) Version

18.2.10

Node Version

v20.18.0

OS Version

22.04.1-Ubuntu SMP

Expected Behaviour

The getStatus() returns a value that represent the consent status.Something like

{deny: false, allow: true, dismiss: false} or

{allow: 'allow'} or

{allow: true}

For reference, documentation is

    /**
     * Gets the current cookie status.
     */
    getStatus(): NgcCookieConsentStatus;

Actual Behaviour

The getStatus() returns a value that gives no indication about the actual status.

{
    "deny": "deny",
    "allow": "allow",
    "dismiss": "dismiss"
}

It is impossible to do anything with that !!

Steps to reproduce the behaviour

Just invoke the service

console.log(this.ccService.getStatus().allow);
console.log(this.ccService.getStatus().deny);
console.log(!!this.ccService.getStatus().allow);
console.log(!!this.ccService.getStatus().deny);
console.log(this.ccService.getStatus());

you will get

app.component.ts:121 allow
app.component.ts:122 deny
app.component.ts:123 true
app.component.ts:124 true
app.component.ts:125 {deny: 'deny', allow: 'allow', dismiss: 'dismiss'}

xOctave avatar Oct 28 '24 10:10 xOctave

I can confirm the same behavior.

Have you managed to find an alternative to retrieve the current status of the user ?

Mehdi-SK avatar Jul 04 '25 10:07 Mehdi-SK