Hello,
I have the following data structure:
[
{id:1,idforeign:2,nome:'etc'},
{id:2,idforeign:2,nome:'etc'},
{id:3,idforeign:3,nome:'outro'},
{id:4,idforeign:3,nome:'outro'}
]
I would like to transform to something like this:
[
{nome:'etc', dados:[
{id:1,idforeign:2},
{id:2,idforeign:2}
]
},
{nome:'outro', dados:[
{id:3,idforeign:3},
{id:4,idforeign:3}
]
}
]
I've tried something like this: Group and add array in JavaScript
But it did not work very well the adaptations I made, does anyone know an easy way to do this?