-
Notifications
You must be signed in to change notification settings - Fork 127
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: allow for custom response parser with parseResponse
#16
Conversation
Thank you for the PR @chrstnfrrs Do you mind adding test cases in https://github.com/unjs/ohmyfetch/blob/main/test/index.test.ts? |
Codecov Report
@@ Coverage Diff @@
## main #16 +/- ##
==========================================
+ Coverage 98.30% 98.43% +0.13%
==========================================
Files 4 4
Lines 59 64 +5
Branches 13 18 +5
==========================================
+ Hits 58 63 +5
Misses 1 1
Continue to review full report at Codecov.
|
@atinux I added two tests. I'm not super satisfied with the current test for the |
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.
Will wait for Pooya to see if he spots any issue in the code
parseResponse
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.
Thanks for contributing 💚 I have made a few adjustments to API to simplify
Closes #13
Description
This PR allows for automatic response parsing to be disabled. This can be accomplished through passing
{ parse: false }
into fetch options.This PR also allows for custom parsing functions to be used. For example,
JSON.parse
can be used by passing{ parse: JSON.parse }
into fetch options.Parsing still defaults to
destr
.