I'm trying to remove a property colorIds from my total json response.
const catalog = (materials) => (finishes) => (colors) =>
materials.map((material) => ({
...material,
finishes: finishes
.filter((finish) => {
const materialId = finish.materialId;
delete finish.materialId;
return materialId == material.id;
})
.map((finish) => ({
...finish,
colors: colors.filter((color, i) => {
const colorIds = finish.colorIds[i];
return colorIds.includes(color._id);
}),
})),
}));
each finish has materialId and colorIds which we don't want so I'm currently deleting the finish.materialId after it's been filtered. I'm trying to do the same for the colorIds as well but it seems that it's needed in the colors inner filter().
I was wondering if there's a way to over come I tried adding subsequent maps to no avail.