-
Notifications
You must be signed in to change notification settings - Fork 192
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
fix: bullet proof APIX response handling #754
Conversation
# Description APIX now renders raw data if it cannot parse the response returned as expected. # Changes 1. Added try/catches in appropriate places. Note that the try/catch in RunIt is probably NOT necessary but the code being wrapped indicates that an error could be thrown (logically it should never happen as the user should always be authenticated). 2. Renamed `parseJson` method to `json2Csv` to better reflect what it does (I was initially confused by the original method name). 3. Created a ShowRaw response handler. 4. Created a fallbackResponseHandler to use ShowRaw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Very clean implementation. Thank you.
'The response body could not be parsed. Displaying raw data.' | ||
) | ||
).toBeInTheDocument() | ||
expect(screen.getByText('I AM A LYING JSON RESPONSE')).toBeInTheDocument() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YES YOU ARE!
@@ -141,6 +137,21 @@ const ShowPDF = (response: IRawResponse) => { | |||
return ShowUnknown(response) | |||
} | |||
|
|||
/** A handler for responses that cannot be parsed */ | |||
const ShowRaw = (response: IRawResponse) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The door has been opened!
Description
APIX now renders raw data if it cannot parse the response returned as expected.
Changes
parseJson
method tojson2Csv
to better reflect what it does (I was initially confused by the original method name).Screen Shots