These are chat archives for angular/angular-2-ionic-2

11th
Sep 2017
Luke Skelhorn
@SCRATK
Sep 11 2017 14:35

I’m having a problem with this

.subscribe(
      token => {
        this.storage.set('hasLoggedIn', true);
        this.storage.set('accessToken', token.access_token);
        this.storage.set('roleId', token.role_id);
      },
      error => {
        this.invalidLogin = true;
      },
      () => {
        this.menuController.enable(true);
        this.storage.get('roleId').then(
          (roleId) => {
            this.roleId = roleId;
            console.log('First Check of role Id is = ' + roleId);
            if(this.roleId == null){
              this.storage.get('roleId').then(
                (roleId) => {
                  console.log('Second Check of role id is = ' + roleId);
                  this.roleId = roleId;
                }
              )
            }
            if(this.roleId == 1){ // Student Role
              this.nav.setRoot(ActionsP);
              this.menuController.enable(true, 'studentMenu');
              loading.dismiss();
            }

the first time i returns null and the second time it returns the item??