title: Vuex: Cannot read property '$store' of undefined
body: <p>I have set up a store in vue.js and can access the state parameters in the computed part of a compoenent:</p>
  
  <pre><code>computed: {
      BASE_URL () {
      return this.$store.state.BASE_URL;  
    }
  </code></pre>
  
  <p>However, when I try to access the store in the methods of the same component:</p>
  
  <pre><code>  methods: {
  
      register: function () {
            axios.post( this.BASE_URL + "/web/register", {
            username: this.username,
            password: this.password,
            email: this.email
          }).then(function(data){
            this.$store.commit('saveToken', data.token);
            console.log('token is set to:',  this.$store.state.token)
          });
      }  
   },
  </code></pre>
  
  <p>I get this error at the console:</p>
  
  <blockquote>
    <p>Uncaught (in promise) TypeError: Cannot read property '$store' of
    undefined</p>
  </blockquote>
  
  <p>I have also tried <code>$store</code> without <code>this</code> but get the same error. </p>
  
  <p>What is wrong here? How can I fix it?</p>