title: Vote button with Vue and Axios
body: <p>I have an vote button in my app to vote for articles or comments. I almost got that to work with ajax but the sync of clicks and counter is the big problem. I now try to do it with vue js because someone recommended to do so referring to <a href="https://stackoverflow.com/questions/52580099/sync-vote-button-with-backend-vote-function">Sync vote button with backend vote function</a>. </p>
  
  <p>I have to say I am new to vue js and hope that someone can help me to get this to work. A little specification how I want it to work. A user can toggle the vote button so it adds +1 or 0 and changes the color like here on stack but only with an up button. </p>
  
  <p>What I have for now sends the request to the backend and stores the vote in the database but I dont know how to set up the counter and color properly. What I have so far.</p>
  
  <pre><code>&lt;template&gt;
    &lt;div&gt;
        &lt;a class="vote" :class="{ active: hasVotes }" @click="vote"&gt;&lt;/a&gt;
        &lt;div class="points"&gt;{{ votes }}&lt;/div&gt;
    &lt;/div&gt;
  &lt;/template&gt;
  
  &lt;script&gt;
      export default {
          data(){
              return{
                  votes: this.voted
              }
          },
  
          props: {
              voted: {
                  required: true,
                  type: Number
              },
              article: {
                  required: true,
                  type: Object
              }
          },
  
          computed: {
              hasVotes() {
                  return this.votes &gt; 0;
              }
          },
  
          methods:{
              vote(){
                  axios.post('/article/vote/' + this.article.id)
                      .then(function (response) {
                          console.log(response.data);
                          this.votes = response.count;
                      });
              }
          }
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>What I have else to say is that it is an laravel 5.7 app with vue.js integrated. Maybe it is better to do it with components...?</p>
  
  <p>Best</p>