mirror of
https://github.com/usebruno/bruno.git
synced 2025-01-22 05:38:40 +01:00
* fix: handle case of text when invalid JSON (#3119) * don't stringify if json is invalid, and maintain indentation if stringified * stringify check --------- Co-authored-by: lohit <lohxt.space@gmail.com>
This commit is contained in:
parent
8b6e55dfc0
commit
938e0560a2
@ -19,16 +19,20 @@ const formatResponse = (data, mode, filter) => {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (data === null) {
|
||||
return data;
|
||||
}
|
||||
|
||||
if (mode.includes('json')) {
|
||||
let isValidJSON = false;
|
||||
|
||||
|
||||
try {
|
||||
isValidJSON = typeof JSON.parse(JSON.stringify(data)) === 'object';
|
||||
} catch (error) {
|
||||
console.log('Error parsing JSON: ', error.message);
|
||||
}
|
||||
|
||||
if (!isValidJSON || data === null) {
|
||||
if (!isValidJSON && typeof data === 'string') {
|
||||
return data;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user