[Vuejs]-Apexchart does not update dynamically using axios

0👍

As Estus Flask mentioned in his comment. The answer to this question is to use the arrow syntax for the “then” argument because it is a callback. Therefore the correct function looks like this:

    methods: {
    uChart: function() {
        axios
            .get('http://my-json-server.typicode.com/apexcharts/apexcharts.js/yearly')
            .then(response => {
                this.$refs.chart1.updateSeries([{
                    name: 'Sales',
                    data: response.data
                }])
            });
        console.log(this.$refs.chart1);
    }
}

For further details around this topic check the answer to this question:
How to access the correct this inside a callback?

Leave a comment