Cookie value undefined in angular 6+

Tags: , ,

i am using angular and node js. i use “CookieService” package

token.service.ts class

 SetToken(token) {
    this.cookieService.set('chat_token', token);

  GetToken() {

trying to use token service in my streams.component.ts but i got undefined in “GetToken” here is my Streams.component.ts

ngOnInit() {
    this.token = this.tokenService.GetToken();

please help me out to solve this.


you just forgot to return the token

  GetToken(): string {
     return this.cookieService.get('chat_token');

Source: stackoverflow