I have an array of objects
const data = [
{
id: 1,
name: "Inventory",
type: "directory",
path: "storage/inventory/",
children: [
{
id: 2,
name: "inventory.yaml",
type: "file",
path: "storage/inventory/inventory.yaml",
},
],
},
{
id: 3,
name: "UI",
type: "directory",
path: "storage/ui/",
children: [
{
id: 10,
name: "config.js",
type: "file",
path: "storage/ui/config.js",
},
{
id: 13,
name: "gulpfile.js",
type: "file",
path: "storage/ui/gulpfile.js",
},
],
},
];
My purpose is to get an array which will include only pathes of the objects which type is "file".
What I am doing now is not giving a proper result:
const data = Object.values(parsed).filter(({ type,path }) => type === "file");
Like
const resultedData = ["storage/inventory/inventory.yaml","storage/ui/config.js","storage/ui/gulpfile.js"]