[Chartjs]-Use fetch to get JSON Data for Chart JS

1👍

The key is to update (or to draw) the chart when the data is ready.

fetch('dataSummary.json')
    .then(res => json)
    .then(function(data) {
        console.log('Request succeeded with JSON response', data[0]);
        // rather the returning data use it to update/populate the chart
    }).catch(function(error) {
        console.log('Request failed', error);
    });

Leave a comment