`body` property not present on Response. Is `_bodyInit` spec compliant?
bobziroll opened this issue Β· comments
I'll be the first to admit I'm a bit out of my depth here, so I'd love to better understand what's going on. TIA for your patience with my limited understanding π
I'm using a library (MirageJS) that uses Pretender, which uses whatwg-fetch
. Pretender appears to be using this fetch polyfill whether the environment has a native fetch or not (another issue/PR I'm posting for them).
The reason it has become a problem for me is that React Router β₯ v6.4.5 started duck-type-checking the Response object that is being intercepted by Pretender (and molded by this polyfill), specifically looking for a property called body
.
According to the Fetch Standard re: Responses, it appears a Response needs to have a body
property to be compliant. However, as far as I can tell, this library always appends a property called _bodyInit
instead of body
. (This is where I'm seeing that)
_bodyInit
is created by the _initBody
method here
It seems to my uneducated-on-fetch-standards-and-responses self that it could be changed to something like
this.body = body
But again, I'm sure I'm just misunderstanding something, and would like to be shown the light. Or perhaps have a chance to submit a PR π
TIA for any guidance or help you can provide!
Hi there, the body property is purposefully not implemented as this polyfill does not support ReadableStreams, which is what the body property is meant to be an instance of -- I'll be closing this as a duplicate of #746 - #1109 - #198 (comment)
If you would like to attempt a ReadableStream polyfill and adding a body property which uses that, I will be happy to review the code