Read Storage Value from Constructor Gives error


When i read value from constructor third time give error.

Uncaught (in promise): TypeError: Cannot read property ‘name’ of null TypeError: Cannot read property ‘name’ of null at

Following is my code.

constructor(public navCtrl: NavController, public navParams: NavParams,
    public loadingCtrl: LoadingController,
    private serviceListService: ServiceListService,
    public storage: Storage,
    public modalCtrl: ModalController
) {

     // Get UserId Value From Storage
    storage.get('UserId').then((val) => {
        if (val != null && val != "") {
            let modal = this.modalCtrl.create(ModalChangeCityPage);
        } else {
            let modal = this.modalCtrl.create(ModalRegisterUserPage);


The error message is complaining about an attempt to read the property ‘name’ of an undefined entity. You have not shown any code referencing a ‘name’ property.



Thanks for your response. One thing i don’t understand is its give error third time. When i come to this page two time it work perfectly, If UserId is not available open ModalRegisterPage or ChangeCityPage.

Why it give error on third time…?


You probably have a race condition, but again it’s impossible for anybody to magically divine what your code looks like.