profile
viewpoint

Ask questionsWebstore instance lost on page refresh

I'm using vue js 2. I have a main file with this code:

 import Vue from 'vue'
 import App from './App.vue'
 import router from './router'

const Store = require('secure-webstore').Store

const store = new Store('user_data', 'lachiquichiqui89')

store.init().then(() => {
  // store is ready
})

Vue.prototype.$store = store

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')

This is working fine...I already store some data in indexeddb....but when I refresh the page, I think maybe the instance is lost, because I'm getting this error trying to get the store object inside a component:

Error: Master key not initialized
at Store.get key [as key] (secure-webstore.js?ee28:31)
at Store.eval (secure-webstore.js?ee28:87)
at Generator.next (<anonymous>)
at fulfilled (secure-webstore.js?ee28:4)

And data it's ok!!, so I don't know how to solve it...please help! cap

AKASHAorg/secure-webstore

Answer questions Master-Y0da

@deiu your suggestion solves part of my problem, but gives me another. After init secure webstore, the first time I interact with the store object is in my Login component, for storing user data, like this:

  //Axios call over here
  info.token = response.data
  self.$store.set('user',  info)

I try your suggest like this on my main.js file:

const start = async() => { 
  await store.init().then(() => {
     // store is ready
     Vue.prototype.$store = store
  })
 }

But now I'm getting this error at login component:

TypeError: Cannot read property 'set' of undefined at eval (Login.vue?7463:99)

useful!

Related questions

No questions were found.
source:https://uonfu.com/
Github User Rank List