There is an array. Using the forEach() function, I want to list all the elements of this array, and then use the push() method to add other elements to it. However, why does the error “Unhandled Promise Rejection: TypeError: Spread syntax requires …iterable not be null or undefined” appear? Please tell me what I’m doing wrong.
const townList = computed(() => {
const items: Town[] = [];
filtredList.value.forEach((group) => {
items.push(...group.towns);
});
return items;
});
When checking the array, Postman outputs the data.