Skip to content

Commit b721132

Browse files
committed
fix: remove comments
Signed-off-by: Muhammad Aaqil <[email protected]>
1 parent e0a6d93 commit b721132

File tree

1 file changed

+25
-35
lines changed

1 file changed

+25
-35
lines changed

packages/rest/src/writer.ts

+25-35
Original file line numberDiff line numberDiff line change
@@ -50,42 +50,32 @@ export function writeResultToResponse(
5050
// TODO(ritch) remove this, should be configurable
5151
// See https://github.com/loopbackio/loopback-next/issues/436
5252
response.setHeader('Content-Type', 'application/json');
53-
// let customResult = result;
54-
// let org: {[key: string]: Object[]} = {};
55-
// if (result && typeof result === 'object') {
56-
// if (Array.isArray(result)) {
57-
// customResult = [];
58-
// result.forEach((item: {[key: string]: Object[]}) => {
59-
// org = {};
60-
// if (typeof item === 'object') {
61-
// Object.keys(item).forEach(key => {
62-
// org[key] = item[key];
63-
// });
64-
// customResult.push(org);
65-
// } else {
66-
// customResult.push(item);
67-
// }
68-
// });
69-
// } else {
70-
// org = {};
71-
// Object.keys(result).forEach(key => {
72-
// console.log('-----------------');
73-
// console.log(key);
74-
// console.log('-----------------');
75-
// org[key] = result[key];
76-
// });
77-
// customResult = org;
78-
// }
79-
// }
53+
let customResult = result;
54+
let org: {[key: string]: Object[]} = {};
55+
if (result && typeof result === 'object') {
56+
if (Array.isArray(result)) {
57+
customResult = [];
58+
result.forEach((item: {[key: string]: Object[]}) => {
59+
org = {};
60+
if (typeof item === 'object') {
61+
Object.keys(item).forEach(key => {
62+
org[key] = item[key];
63+
});
64+
customResult.push(org);
65+
} else {
66+
customResult.push(item);
67+
}
68+
});
69+
} else {
70+
org = {};
71+
Object.keys(result).forEach(key => {
72+
org[key] = result[key];
73+
});
74+
customResult = org;
75+
}
76+
}
8077
// TODO(bajtos) handle errors - JSON.stringify can throw
81-
// result = JSON.stringify(customResult);
82-
console.log('------------before------------');
83-
console.log(result);
84-
console.log('------------before------------');
85-
result = JSON.stringify(result);
86-
console.log('------------after------------');
87-
console.log(result);
88-
console.log('------------after------------');
78+
result = JSON.stringify(customResult);
8979
}
9080
break;
9181
default:

0 commit comments

Comments
 (0)