localStorage does not work

I have 2 pages, Home and Settings.
Home is supposed to get category from the localstorage. But its failing to do so.

    getDefaults(){
        if(localStorage.getItem('category') != null){
            this.category = localStorage.getItem('category');
        } else {
            this.category = 'sports';
        }
    }

    changeCategory(){
        this.getPosts(this.category, this.limit);
    }

I have settings page like this

    getDefaults(){
        if(localStorage.getItem('category') != null){
            this.category = localStorage.getItem('category');
        } else {
            this.category = 'sports';
        }

        if(localStorage.getItem('limit') != null){
            this.limit = localStorage.getItem('limit');
        } else {
            this.limit = 10;
        }
    }

    setDefaults(){
        localStorage.setItem('category', this.category);
        localStorage.setItem('limit', this.limit);
        this.navCtrl.push(HomePage);
    }

All I want to do is from the settings page when I change category not to use navCtrl.push and create a new page that would go back to settings but move it to HomePage.

Please edit your title to tell something about your problem.

Also:
What does “failing” mean? Does it go into the null fallback and set it to “sports”? Or what happens?
What is localStorage? What library?
What is your ionic info output?

I set the localstorage to music from settings.
But the home page is not updated

Doesn’t getItem return a Promise? I use Ionic Storage and the get function returns a Promise. Your code acts as though it returns a synchronous object immediately.

The new title is not better. “localStorage does not work” or something similar seems to be your actual problem.

Also you didn’t answer any of my questions.

I am not getting any log errors

Do you want this data to persist across app restarts?

That is great. You also don’t answer questions I asked you, so I stop helping you now. Good luck.

I did answer 2 of your questions.