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({
  render: h => h(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 (<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


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 =
  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)


Related questions

No questions were found.
Github User Rank List