title: Accessing the data from localstorage from another route with vuex
body: <p>i am getting the data from a config panel route setting it to the localstorage with vuex , storeJS:</p>
  <pre><code>     const state = {
        message: [],
        // console.log(message);
        sec: 0,
        // other state
      };
      const getters = {
        message: (state) =&gt; {
          // console.log(this.state.message);
      
          return state.message;
        },
      
        sec: (state) =&gt; {
          return state.sec;
        },
        // other getters
      };
      
      const actions = {
        setMessage: ({ commit, state }, inputs) =&gt; {
          commit(
            'SET_MESSAGE',
            inputs.map((input) =&gt; input.message)
          );
      
          return state.message;
        },
  
    setSec: ({ commit, state }, newSecVal) =&gt; {
      commit('SET_TIMEOUT', newSecVal);
      return state.sec;
    },
    // other actions
  };
  const mutations = {
    SET_MESSAGE: (state, newValue) =&gt; {
      state.message = newValue;
      localStorage.setItem('message', JSON.stringify(newValue));  -----&gt;this
    },
    SET_TIMEOUT: (state, newSecVal) =&gt; {
      state.sec = newSecVal;
      localStorage.setItem('sec', JSON.stringify(newSecVal));  ---&gt;this
    },
    // other mutations
  };
  
  export default {
    state,
    getters,
    actions,
    mutations,
  };
  </code></pre>
  <p>Now i am having a home route where i want to display this ,how can i access that?</p>
  <p>I am getting the data (not the localstorage but the regular state data)   with Mapgetters  and i am using it like that:</p>
  <pre><code>computed: {
     
  
      ...mapGetters({
        message: &quot;message&quot;,
        sec: &quot;sec&quot;
      }),
  </code></pre>
  <p>how can i tell him that if there is nothing (when a page reloads ) to automaticcally get the data from localstorage.
  This is my MOunted</p>
  <pre><code>mounted() {
      this.$store.dispatch(&quot;SET_MESSAGE&quot;);
      this.$store.dispatch(&quot;SET_SEC&quot;);
   
      
    },
  </code></pre>