comment
This commit is contained in:
parent
8b7de2a0ba
commit
48e7aa0906
1 changed files with 25 additions and 25 deletions
|
|
@ -169,32 +169,32 @@ export class ApiWebServiceController extends Controller {
|
|||
};
|
||||
await this.apiHistoryRepository.save(history);
|
||||
|
||||
const results = data.map((item) => {
|
||||
const flattenedItem: any = {};
|
||||
// const results = data.map((item) => {
|
||||
// const flattenedItem: any = {};
|
||||
|
||||
// Extract nested object properties to top level
|
||||
Object.keys(item).forEach((key) => {
|
||||
const value = item[key];
|
||||
if (value && typeof value === "object") {
|
||||
// if (Array.isArray(value) && value.length === 1) {
|
||||
// // If array has single item, extract it as object
|
||||
// Object.assign(flattenedItem, value[0]);
|
||||
// } else
|
||||
if (!Array.isArray(value)) {
|
||||
// Merge nested object properties to top level
|
||||
Object.assign(flattenedItem, value);
|
||||
} else {
|
||||
// Keep arrays with multiple items or empty arrays as is
|
||||
flattenedItem[key] = value;
|
||||
}
|
||||
} else {
|
||||
// Keep primitive values as is
|
||||
flattenedItem[key] = value;
|
||||
}
|
||||
});
|
||||
// // Extract nested object properties to top level
|
||||
// Object.keys(item).forEach((key) => {
|
||||
// const value = item[key];
|
||||
// if (value && typeof value === "object") {
|
||||
// // if (Array.isArray(value) && value.length === 1) {
|
||||
// // // If array has single item, extract it as object
|
||||
// // Object.assign(flattenedItem, value[0]);
|
||||
// // } else
|
||||
// if (!Array.isArray(value)) {
|
||||
// // Merge nested object properties to top level
|
||||
// Object.assign(flattenedItem, value);
|
||||
// } else {
|
||||
// // Keep arrays with multiple items or empty arrays as is
|
||||
// flattenedItem[key] = value;
|
||||
// }
|
||||
// } else {
|
||||
// // Keep primitive values as is
|
||||
// flattenedItem[key] = value;
|
||||
// }
|
||||
// });
|
||||
|
||||
return flattenedItem;
|
||||
});
|
||||
return new HttpSuccess({ data: results, total });
|
||||
// return flattenedItem;
|
||||
// });
|
||||
return new HttpSuccess({ data: data, total });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue