Reputation: 7240
I need to set a cookie as below:
start: number;
...
this.start = Math.floor(Date.now()/1000);
...
if(!this._cookieService.check('confirmTimeoutStarted')){
this._cookieService.set('confirmTimeoutStarted', this.start);
}
But I get:
error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
Am I supposed to define the cookie variable type or something?
Upvotes: 0
Views: 7596
Reputation: 2454
Cookies are stored in string format. It looks like the signature of the this._cookieService.set
method accepts string, so you can do this:
this._cookieService.set('confirmTimeoutStarted', String(this.start));
Upvotes: 2