[Vuejs]-Use ES6 arrow function as AJAX callback handler

0👍

You might want to give some additional context, since the documentation you’ve linked alongside the promise handler arrow function works perfectly fine.

new Vue({
  data: {
    a: 1
  },
  created: function () {
    console.log(this.a, this.supplierCount);
    axios.get("https://api.myjson.com/bins/xva5k").then(response => {
      this.supplierCount = _.uniqBy(response.data, 'groupNumber').length;
      console.log(this.a, this.supplierCount);
    });
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.0/axios.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js"></script>

Leave a comment