I'm doing my first steps with ionic and I ask me if I can use this in an ionic application:
import {LocalStorageService} from 'ngx-webstorage';
or is there a better way to store login data of user after authentification?
CodePudding user response:
When saying login data, I suppose you're referring to the user's token? Because you should not be storing any user credentials locally.
Other than that, there are various threads about this topic, ie localStorage vs cookies, see this or something more recent.
But to answer your question, there is no reason as to why you shouldn't be able to use that package, seeing how it offers a variety of quality-of-life improvements and useful handlers.
CodePudding user response:
Ionic already provides a storage abstraction, you can use it without importing external packages.
import { Storage } from '@ionic/storage';
private store: Storage;
constructor(private storage: Storage) { }
async init() {
this.store = await this.storage.create();
}
save(userData: any) {
this.store.set('user', userData);
}
See https://github.com/ionic-team/ionic-storage for details