Good morning,
I would like to use the “Store” function for the user login instead of the localStorage, but I see that when I refresh the page the store is reset. Is there any way to fix it or do you have any advice?
App target:
-
Web
-
Cordova (Android/IOS)
Code:
on click button login:
app.request({
method: 'POST',
url: page,
crossDomain: true,
dataType: 'json',
data: obj,
success: function (data) {
app.store.dispatch('updateUser', data);
app.views.main.router.navigate(`/`, {reloadCurrent: true});
app.preloader.hide();
}
});
Store.js:
import { createStore } from 'framework7';
const store = createStore({
state: {
user: null,
},
actions: {
updateUser( { state }, userData) {
state.user = userData || null;
},
},
})
export default store;
For now the only option that came to my mind is to use this plugin saving and encrypting the localStorage then using the store when starting the app, if you have better ways thank you for the help