/** renameFields items->children **/
const renameFields = (obj) => ({
name: obj.title,
url: obj.url,
children: obj.items,
});
/** transform Data **/
const transformData = (data) => {
const renamedData = renameFields(data);
if(data.items) {
renamedData.children = renamedData.children.map((child) => renamedData(child));
return renamedData;
}
if(data.items === null) {
renamedData.children = [];
return renamedData;
}
return renamedData;
}