0👍
Your lessonsCourse
property gets overwritten in each forEach
cycle.
You can use spread operator to concatenate the section lessons array to your main array:
this.eventCourse.forEach(course => {
course.sections.forEach(section => {
this.lessonsCourse = [...this.lessonsCourse, ...section.lessons];
});
});
Or, if your compiler doesn’t support spread syntax using push:
this.eventCourse.forEach(course => {
course.sections.forEach(section => {
section.lessons.forEach(lesson => {
this.lessonsCourse.push(lesson);
});
});
});
- [Vuejs]-Stop the multiple display of an element in VueJS – Fancybox
- [Vuejs]-Why isnt vue-chartjs receiving data from api?
Source:stackexchange.com