title: How can i call a Rest API from a Vue component?
body: <p>I'm just getting started to VueJS and i'm trying to create a  very simple page where a pie chart with some data is shown.</p>
  <p>Right now, i managed to display the chart using example data, but now i would like to populate the chart with data retrieved from an api call on my backend <code>http://127.0.0.1:8000/user/getamount</code>.</p>
  <p>Here is my code:</p>
  <p><strong>chart.js</strong></p>
  <pre><code>import Vue from &quot;vue/dist/vue.js&quot;;
  import Vuex from &quot;vuex&quot;;
  import storePlugin from &quot;./vuex/vuex_store_as_plugin&quot;;
  import App from './App.vue'
  import HighchartsVue from &quot;highcharts-vue&quot;;
  import axios from 'axios'
  import VueAxios from 'vue-axios'
  
  Vue.use(Vuex);
  Vue.use(storePlugin);
  Vue.config.productionTip = false;
  Vue.use(HighchartsVue);
  Vue.use(VueAxios, axios)
  
  
  new Vue({
    el: &quot;#app&quot;,
    render: h =&gt; h(App),
  });
  </code></pre>
  <p><strong>App.vue</strong></p>
  <pre><code>&lt;template&gt;
    &lt;div&gt;
      &lt;highcharts class=&quot;hc&quot; :options=&quot;chartOptions&quot; ref=&quot;chart&quot;&gt;&lt;/highcharts&gt;
    &lt;/div&gt;
  &lt;/template&gt;
  
  &lt;script&gt;
  
  export default {
    data() {
      return {
        chartOptions: {
          series: [{
  
             type: 'pie',
             name: 'Browser share',
             data: [
                ['Firefox',   45.0],
                ['IE',       76.8],
                ['Safari',    8.5],
                ['Opera',     6.2],
                ['Others',   0.7]
             ]
          }],
  
        }
      };
    }
  };
  &lt;/script&gt;
  </code></pre>
  <p>I just got to started to Vue so a lot of stuff is not clear yet, but where am i supposed to perform the API request here? I've seen a lot of examples where axios is used to call an API and show data on the page, but in this case i need data on my component, since the chart it's there. Should i just perform the call from the component? Or am i missing something? Any kind of advice is appreciated</p>