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

Avoid parsing JSON twice in _pagination.transform #1102

Merged
merged 3 commits into from Mar 3, 2020

Conversation

jaulz
Copy link
Contributor

@jaulz jaulz commented Mar 3, 2020

If the responseType is json we do not need to parse the response again in the default transform function.

Checklist

  • I have read the documentation.
  • I have included a pull request description of my changes.
  • I have included some tests.
  • If it's a new feature, I have included documentation updates.

@szmarczak
Copy link
Collaborator

This needs a test 👍

@szmarczak szmarczak changed the title feat: avoid parsing JSON in transform if responseType is JSON Avoid parsing JSON in _pagination.transform if the responseType is json already Mar 3, 2020
@szmarczak
Copy link
Collaborator

Instead of the check I'd just put normalizedOptions.responseType = 'text'; in

@jaulz
Copy link
Contributor Author

jaulz commented Mar 3, 2020

I would rather use the passed options and not change them in between. That might lead to an unexpected behavior in the future.

@szmarczak
Copy link
Collaborator

Hmmm. You're right.

@szmarczak szmarczak changed the title Avoid parsing JSON in _pagination.transform if the responseType is json already Avoid parsing JSON twice in _pagination.transform Mar 3, 2020
@szmarczak szmarczak merged commit cf4fdad into sindresorhus:master Mar 3, 2020
@szmarczak
Copy link
Collaborator

Good job! 🙌

@jaulz jaulz deleted the patch-4 branch March 3, 2020 13:55
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.

None yet

2 participants