Skip to content

Commit 938e056

Browse files
TheoD02lohxt1
andauthored
fix: handle case of text when invalid JSON (usebruno#3119) (usebruno#3120)
* fix: handle case of text when invalid JSON (usebruno#3119) * don't stringify if json is invalid, and maintain indentation if stringified * stringify check --------- Co-authored-by: lohit <[email protected]>
1 parent 8b6e55d commit 938e056

File tree

1 file changed

+6
-2
lines changed
  • packages/bruno-app/src/components/ResponsePane/QueryResult

1 file changed

+6
-2
lines changed

Diff for: packages/bruno-app/src/components/ResponsePane/QueryResult/index.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@ const formatResponse = (data, mode, filter) => {
1919
return '';
2020
}
2121

22+
if (data === null) {
23+
return data;
24+
}
25+
2226
if (mode.includes('json')) {
2327
let isValidJSON = false;
24-
28+
2529
try {
2630
isValidJSON = typeof JSON.parse(JSON.stringify(data)) === 'object';
2731
} catch (error) {
2832
console.log('Error parsing JSON: ', error.message);
2933
}
3034

31-
if (!isValidJSON || data === null) {
35+
if (!isValidJSON && typeof data === 'string') {
3236
return data;
3337
}
3438

0 commit comments

Comments
 (0)