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

Only apply response interceptor transformations to JSON responses #79

Merged
merged 2 commits into from
Dec 16, 2024

Conversation

rbruggem
Copy link
Member

If the response returns other types of content, for instance 'application/pdf' or 'image/png', applying the transformation is incorrect.

If the response returns other types of content, for instance
'application/pdf' or 'image/png', applying the transformation is
incorrect.
Copy link
Collaborator

@raguiar9080 raguiar9080 left a comment

Choose a reason for hiding this comment

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

I wonder if our response object should have both the camelCase and snake_case objects present 🤔

Nevertheless, LGTM 👍

// Convert to camelCase when receiving JSON responses
const camelCaseResponse = (response: AxiosResponse): ExtendedAxiosResponse => {
const contentType = response.headers['content-type']
if (contentType && contentType.includes('application/json')) {

Choose a reason for hiding this comment

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

nitpick: If we do an early return we can avoid indenting all that code

if (!contentType || !contentType.includes('application/json')) {
    return response
}
...

@rbruggem
Copy link
Member Author

I wonder if our response object should have both the camelCase and snake_case objects present 🤔

Nevertheless, LGTM 👍

I wonder whether transforming everything to camelCase was a mistake.

@rbruggem rbruggem merged commit bb3e42b into master Dec 16, 2024
1 check passed
@rbruggem rbruggem deleted the transformation-json branch December 16, 2024 11:23
rbruggem added a commit that referenced this pull request Dec 16, 2024
This includes fixes to non-`application/json` response payloads (#79).
@rbruggem rbruggem mentioned this pull request Dec 16, 2024
rbruggem added a commit that referenced this pull request Dec 16, 2024
This includes fixes to non-`application/json` response payloads (#79).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants