Storage doesn't clear, there seems to be multiple instances


I use ionic/storage in two different views. In my login page I set the user token and I clear it in the profile page when the user logs out. The problem is, when the user logs out, the storage does not get cleared in the login page. I know this because when I go back to the login page, I can directly log back in using the token in storage (which was supposed to be removed). However, in the profile page it actually clears the storage. When I call storage.clear() from the login page, then it clears properly.

I think I somehow made two instances of storage… any help would be much appreciated!

Here is how I import & use storage:


import { Storage } from ‘@ionic/storage’;

let storage = new Storage();

providers: [
// config values for AuthHttp

  tokenGetter: (() => storage.get('id_token')),

}) ]


import { Storage } from '@ionic/storage';
   constructor(... public storage: Storage...) {
            ... = storage;

     ...'id_token', uData.token);



import { Storage } from '@ionic/storage';

constructor(... storage: Storage...) {
                ... = storage;

logout() {		
		console.log('log out was called!');
		var self = this;
			data => {
				console.log('id_token')); // this print shows the existing token;
				console.log('id_token')); // this print shows the token is removed, {});
			error => {


Nevermind, I was logging the user in automatically in the login page, that’s why when I logged out it was logging the user in but staying in the same page :slight_smile:


Regardless of anything else, you don’t need to be doing this:


Thank you! But then how do I set the tokenGetter for the authHttp? is that redundant as well?

tokenGetter: (() => storage.get('id_token')),