When working with object attributes, keep in mind that they only hold the first element of the assigned value
let groupedDepActivities=[]
groupedDepActivities.push({
id:1,
term_activity:{
terms:[{id:1},{from:'here'},{to:'there'},]
}
})
If you use console.log()
, the result will show:
*
term_activity:
terms: Array(1)
0:
id: "1"
[[Prototype]]: Object
length: 1
*
Remember, the terms attribute only holds the first element(id:1) of the array, not all elements