Having recently delved into Vue, I'm having trouble figuring out how to solve this issue. Let me begin by showing you the code snippet followed by explaining the problem at hand. Currently, I am utilizing Vue-Good-Table for this project.
methods:{
getTotals(){
var self = this;
var new1=[];
this.$http.get('http://localhost:3000/api/purchases')
.then(function (response) {
console.log("response.data value")
console.log(response.data)
for (var i = 0; i < response.data.length; i++) {
var item1=JSON.parse(response.data[i].pur_items);
console.log("item1 for index i time" +i)
console.log(item1)
new1=item1
}
console.log("final output")
console.log(new1)
})
},
Upon reviewing the console log from the 'for loop', https://i.sstatic.net/a9ayt.png it seems that instead of receiving 5 arrays in the final output stored in 'new1', only 2 arrays are displayed during the last iteration. Any suggestions on what I may be doing incorrectly?