Not able to add elements to an array in typescript using chart.js and bootstrat charts

๐Ÿ‘:1

If you are calling the method showDailyStats after the dailyStatistics you have to use async/await to wait for the data to come into the array before accessing its content.

๐Ÿ‘:0

You can assign result of asynchronous call directly in subscribe without using map method and then call your method showDailyStats:

.subscribe( r => {
    this.dailyStats = r; //console log prints the whole array all of them!
    this.showDailyStats();
}

Leave a comment