Skip to content

Commit

Permalink
fix: remove comments
Browse files Browse the repository at this point in the history
Signed-off-by: Muhammad Aaqil <[email protected]>
  • Loading branch information
aaqilniz committed Sep 26, 2024
1 parent e0a6d93 commit b721132
Showing 1 changed file with 25 additions and 35 deletions.
60 changes: 25 additions & 35 deletions packages/rest/src/writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,42 +50,32 @@ export function writeResultToResponse(
// TODO(ritch) remove this, should be configurable
// See https://github.com/loopbackio/loopback-next/issues/436
response.setHeader('Content-Type', 'application/json');
// let customResult = result;
// let org: {[key: string]: Object[]} = {};
// if (result && typeof result === 'object') {
// if (Array.isArray(result)) {
// customResult = [];
// result.forEach((item: {[key: string]: Object[]}) => {
// org = {};
// if (typeof item === 'object') {
// Object.keys(item).forEach(key => {
// org[key] = item[key];
// });
// customResult.push(org);
// } else {
// customResult.push(item);
// }
// });
// } else {
// org = {};
// Object.keys(result).forEach(key => {
// console.log('-----------------');
// console.log(key);
// console.log('-----------------');
// org[key] = result[key];
// });
// customResult = org;
// }
// }
let customResult = result;
let org: {[key: string]: Object[]} = {};
if (result && typeof result === 'object') {
if (Array.isArray(result)) {
customResult = [];
result.forEach((item: {[key: string]: Object[]}) => {
org = {};
if (typeof item === 'object') {
Object.keys(item).forEach(key => {
org[key] = item[key];
});
customResult.push(org);
} else {
customResult.push(item);
}
});
} else {
org = {};
Object.keys(result).forEach(key => {
org[key] = result[key];
});
customResult = org;
}
}
// TODO(bajtos) handle errors - JSON.stringify can throw
// result = JSON.stringify(customResult);
console.log('------------before------------');
console.log(result);
console.log('------------before------------');
result = JSON.stringify(result);
console.log('------------after------------');
console.log(result);
console.log('------------after------------');
result = JSON.stringify(customResult);
}
break;
default:
Expand Down

0 comments on commit b721132

Please sign in to comment.