In my example, I have an array of objects which I want to map to another array of objects:
Resurs.map((item) => ({
Cen: item.Cent,
level: [
item.NumList.map((item) => ({
Kom: item.Number,
Num: item.Kor,
})),
item.SerList.map((item) => ({
Kom2: item.Ser,
})),
],
}));
So, I have 2 map methods inside the map method. It will return:
{
Cen: "aaa",
level: [
[ // -> want to get rid of this
{
Kom: "aaa",
Num: "aaa",
},
{
Kom: "bbb",
Num: "bbb",
},
], // -> and this
[ //-> and this
{ Kom2: "aaa" },
{ Kom2: "bbb" },
], //-> and this
],
};
So, both map functions need to be inside level
key, but not as a list which has two lists inside, but as a list with objects.
So, I want to achieve:
{
Cen: "aaa",
level: [
{
Kom: "aaa",
Num: "aaa",
},
{
Kom: "bbb",
Num: "bbb",
},
{ Kom2: "aaa" },
{ Kom2: "bbb" },
],
};