title: VueJS and axios - how to access data in a post request
body: <p>I have got data like this:</p>
  <pre><code>  data: () =&gt; ({
      input: {
        username: &quot;&quot;,
        password: &quot;&quot;
      }
    }),
  </code></pre>
  <p>and make a post request like this:</p>
  <pre><code>loggin_in() {
    if (this.input.username != &quot;&quot; &amp;&amp; this.input.password != &quot;&quot;) {
      console.log(this.input.username);
      axios
        .post(&quot;http://localhost:5000/login&quot;, {
          email: this.input.username,
          password: this.input.password
        })
        .then(function(data) {
          console.log(data);
        })
        .catch(function(error) {
          console.log(this.input.username);
        });
    }
  }
  </code></pre>
  <p>Logging the first <code>this.input.username</code> works, but after that, I have no idea how to access the data. <code>this</code> seems to be undefined.</p>
  <pre><code>Uncaught (in promise) TypeError: Cannot read property 'input' of undefined
  </code></pre>
  <p>I dont know why the context of <code>this</code> changes here and don´t get how to access my data. Can anybody explain me whats going on and help me with this?</p>