Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

stateService.ts:530 TypeError: Cannot read property 'getCookie' of null #71

@jelling

Description

@jelling

I'm attempting to use the angular 2 sdk but receive the following error:

stateService.ts:530 TypeError: Cannot read property 'getCookie' of null
at CookieXSRFStrategy.configureRequest (xhr_backend.js:206)
at XHRBackend.createConnection (xhr_backend.js:261)
at httpRequest (http.js:24)
at StormpathHttp.Http.request (http.js:133)
at StormpathHttp.request (stormpath.http.ts:44)
at StormpathHttp.Http.get (http.js:147)
at Stormpath.getAccount (stormpath.service.ts:116)
at new Stormpath (stormpath.service.ts:103)
at AppModuleInjector.get (/AppModule/module.ngfactory.js:239)
at AppModuleInjector.getInternal (/AppModule/module.ngfactory.js:474)
at AppModuleInjector.NgModuleInjector.get (core.umd.js:9003)
at MergeInjector.get (mergeInjector.ts:31)
at ReflectiveInjector_.getByKeyDefault (core.umd.js:3434)
at ReflectiveInjector
.getByKey (core.umd.js:3384)
at ReflectiveInjector
.get (core.umd.js:3144)

Here's my typescript component:

import {
  Component,
  Inject
} from "@angular/core";

import { Stormpath, Account } from 'angular-stormpath';
import { Observable } from 'rxjs';

@Component({
  selector: "checkout",
  templateUrl: "onboard/templates/onboard.html",
  styleUrls: ["onboard/styles/onboard.css"]
})
export class Onboard {
  name: string = `yo, I"m your component :D`;

  // TODO: move all of this stormpath stuff to a component that will be the root component for customer area || entire app
  private user$: Observable<Account | boolean>;
  private loggedIn$: Observable<boolean>;
  private login: boolean;
  private register: boolean;
 
  constructor(public stormpath: Stormpath) {
  }
 
  ngOnInit() {
    this.login = true;
    this.register = false;
    this.user$ = this.stormpath.user$;
    this.loggedIn$ = this.user$.map(user => !!user);
  }
 
  showLogin() {
    this.login = !(this.register = false);
  }
 
  showRegister() {
    this.register = !(this.login = false);
  }
 
  logout() {
    this.stormpath.logout();
  }

}

Any ideas? I'm following the getting started tutorial here: https://stormpath.com/blog/angular-2-user-authentication

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions