Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: display raw query response unformatted for readability #2272

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 0 additions & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,22 @@ const formatResponse = (data, mode, filter) => {
return '';
}

if (mode.includes('json')) {
let isTrueJSON;
try {
isTrueJSON = typeof JSON.parse(JSON.stringify(data)) === 'object';
} catch (error) {
console.log('Error parsing JSON: ', error.message);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Console output is not required here, I think?

Suggested change
console.log('Error parsing JSON: ', error.message);
console.log('Error parsing JSON: ', error.message);

Copy link
Author

@DawoodMorris DawoodMorris May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that (the console.log) is not required. It was for inspection purposes. We can remove it.

isTrueJSON = false;
}

if (mode.includes('json') && isTrueJSON) {
if (filter) {
try {
data = JSONPath({ path: filter, json: data });
} catch (e) {
console.warn('Could not filter with JSONPath.', e.message);
}
}

return safeStringifyJSON(data, true);
}

Expand All @@ -35,15 +42,14 @@ const formatResponse = (data, mode, filter) => {
if (typeof parsed === 'string') {
return parsed;
}

return safeStringifyJSON(parsed, true);
}

if (typeof data === 'string') {
return data;
}

return safeStringifyJSON(data);
//return safeStringifyJSON(data)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to remove commented code.

Suggested change
//return safeStringifyJSON(data)
//return safeStringifyJSON(data)

return data;
};

const QueryResult = ({ item, collection, data, dataBuffer, width, disableRunEventListener, headers, error }) => {
Expand Down