Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

310
Views
Loading data from API into vue.js using chart.js

I am relatively new to Vuejs and API calling and I wanna find out how to fetch data from my API to display chart.

Currently, my code is:

<script>
import axios from 'axios'

export default {
  name: 'Chart',

  props: ['data'],

  data: () => ({

  }),
  async mounted () {

    let result = await axios.get('http://api.marketstack.com/v1/eod?access_key=b2508f27f2cef3694a66d6adf4646f87&symbols=AAPL')
    this.data = result.data.data

    // eslint-disable-next-line no-unused-vars
    const data = ????? #need help here
    }))

    const ctx = document.getElementById('mychart').getContext('2d')
    // eslint-disable-next-line no-undef,no-unused-vars
    const Chart_2 = new Chart(ctx, {
      type: 'line',
      data: {
        datasets: [
          {
            data,
            label: 'Chart from API ',
            borderColor: '#7367F0'
          }
        ]
      },
      options: {
        scales: {
          xAxes: [
            {
            }
          ],
          yAxes: [
            {
            }
          ]
        }
      }
    })
  }
}

The above code is in a component Chart2.vue and will be displayed in App.vue. Would appreciate any help given!

The API URL: http://api.marketstack.com/v1/eod?access_key=b2508f27f2cef3694a66d6adf4646f87&symbols=AAPL

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!