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
Add safe checking of payload data type to prevent undefined errors #23
Conversation
Solid!! |
This a WIP still? See it's back in draft mode... |
Either way, killer job you two! |
@kwhitley sorry yeah I think it's ready for review. Def need to improve the type checking to be more robust tho |
const is_blob = typeof Blob !== 'undefined' && payload instanceof Blob | ||
const is_arraybuffer = typeof Uint8Array !== 'undefined' && payload instanceof Uint8Array | ||
const passthrough = is_formdata || is_blob || is_arraybuffer | ||
|
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.
Gulp.
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.
Granted this should minify somewhat...
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.
I think you can make this smaller by keying on 'raw' post content vs stringify post content:
fetcher.post('/whatever', raw(myBlobHere))
A tiny function raw
could simply tag the object with a symbol to skip the stringification...
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.
Ok, live in |
This fixed issues where Blob/FormData are being reported as undefined. It also makes our auto content-type/
JSON.stringify
code work more reliably.Also added checking for
Uint8Array
. May eventually need to support more content types.Thanks to @Crisfole for the tip on using
typeof FormData !== "undefined"
!Closes #16
Closes #21