methods: {
fetchData: function () {
console.log("I am currently inside the fetchData function ...")
var courseTable = this.$parse.Object.extend(this.course);
const query = new this.$parse.Query(courseTable);
const results = query.find().then(res => {
const arrayLength = res.length;
for (var i = 0; i < arrayLength; i++) {
const item = res[i];
const index = item.get("index");
const text = item.get("text");
const audio = item.get("audio");
this.courseResults.push({ "index": index, "text": text, "audio": audio });
}
console.log(this.courseResults);
});
},
}
When I try to use push inside a for loop, it gives me an error saying "item get is not a function." However, when I remove this line:
this.courseResults.push({"index": index, "text": text, "audio": audio});
How can I resolve this issue?
I could move this code outside the for loop, and that would solve the problem.
this.courseResults = res;
But, I want to edit the first response. Thank you.