title: localStorage.getItem() always returns null even when value exists
body: <p>Im not sure If I am doing something wrong or if I have a typo somewhere, but I am trying to compare dates in a vue project but the value I pull from my local storage always returns null even when I can see the value clearly exists when I check my local storage. so here is the set up.</p>
  
  <p>after making a request I set the expires date in local storage like so</p>
  
  <pre><code>retrieveToken({ commit }, credentials) {
  
        return new Promise((resolve, reject) =&gt; {
            axios.post('/login', {
                username: credentials.username,
                password: credentials.password,
            })
            .then(response =&gt; {
                const token = response.data.access_token
                const date = new Date(moment().add(30, 'seconds').toDate());
                localStorage.setItem('expires_on', date)
                localStorage.setItem('access_token', token)
                resolve(response)
            })
            .catch(error =&gt; {
                console.log(error.response.data)
                reject(error)
            })
        })
      },
  </code></pre>
  
  <p>I can then see that the <code>expires on</code> has been placed in my local storage
  <a href="https://i.stack.imgur.com/Ewgm1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ewgm1.png" alt="enter image description here"></a></p>
  
  <p>I then want to use a getter to retrieve that value like so</p>
  
  <pre><code>tokenExpires() {
        return localStorage.getItem('expires_on')
      },
  </code></pre>
  
  <p>So i can use like this</p>
  
  <pre><code>computed: {
          ...mapGetters(['tokenExpires']),
      },
  methods: {
       destroySessionIfTokenIsExpired() {
              const current = new Date(moment())
              const expires = this.tokenExpires
              const currentDate = moment(current).format('YYYYMMDDHHMMSS')
              const expiresDate = moment(expires).format('YYYYMMDDHHMMSS')
                  console.log(this.tokenExpires)
                  console.log(expiresDate)
              if(currentDate &gt;= expiresDate) {
                  this.$store.dispatch('destroyToken')
                  .then(() =&gt; {
                      this.$router.push('/login')
                      alert('Your Session Has Expired, Please Log Back In')
                  })
              } else return;
          }
         }
  </code></pre>
  
  <p>but when I run this method and console.log(this.tokenExpires) it returns null and I am not sure why. If anybody can see what I am doing wrong please let me know!!</p>
  
  <p>*Update, my issue is that I am trying to watch the routes and run a comparison of timestamps to see if the session is still valid but as pointed out, the <code>getter</code> does not have enough time to compute the value before the method runs, so any suggestions on how I could get around that would be awesome. here is the route watch method</p>
  
  <pre><code>watch: {
          '$route': function(to, from) {
              this.destroySessionIfTokenIsExpired()
          }
      },
  </code></pre>