title: vue-chartjs in laravel,vuejs using API Axios
body: <p>I am trying to show the all the companies in the Chart in Dashboard.vue regarding years but it does not show anything and I am trying since many days if someone could help me it will be so kind of him.</p>
  
  <blockquote>
    <p>My API/Route is :</p>
  </blockquote>
  
  <pre><code>Route::apiResources(['company'=&gt;'API\CompanyController']);
  </code></pre>
  
  <blockquote>
    <p>EmployeeController code is :</p>
  </blockquote>
  
  <pre><code>public function index(){return Employee::all();}
  </code></pre>
  
  <blockquote>
    <p>Code in Chart.vue  is:</p>
  </blockquote>
  
  <pre><code>&lt;script&gt;
  import { Line } from "vue-chartjs";
  export default {
    extends: Line,
    data() {
      return {
        url: "api/company",
        years: [],
        labels: [],
  
        data: ""
      };
    },
  
    methods: {
      getProducts() {
        axios.get(this.url).then(response =&gt; {
          this.data = response.data;
          if (this.data) {
            this.data.forEach(element =&gt; {
              this.years.push(element.created_at);
              this.labels.push(element.name);
  
            });
            this.renderChart(
              {
                labels: this.years,
                datasets: [
                  {
                    label: "list of Companies ",
                    backgroundColor: "#f87979",
                    data: this.name
                  }
                ]
              },
              { responsive: true, maintainAspectRatio: false }
            );
          } else {
            console.log("NO DATA");
          }
        });
      }
    },
    mounted() {
      this.getProducts();
    }
  };
  &lt;/script&gt;
  </code></pre>
  
  <blockquote>
    <p>Code in app.js is :</p>
  </blockquote>
  
  <pre><code>Vue.component('chart-component', require('./components/Chart.vue'));
  </code></pre>
  
  <blockquote>
    <p>code in Dashboard is :</p>
  </blockquote>
  
  <pre><code>&lt;template&gt;
    &lt;div class="container"&gt;
  
      &lt;chart-component&gt;&lt;/chart-component&gt;
    &lt;/div&gt;
  &lt;/template&gt;
  </code></pre>