beaker-core
beaker-core copied to clipboard
Response returned by experimental.globalFetch should have non empty`.url`
At the moment Response instance returned by experimental.globalFetch always has a url: "" which as I've encountered seems to break general assumptions around existing code bases.
Digging through the spec it does appear like there is a way to provide url of the constructed Response instance, but it's possible to do on subclass:
class MyResponse extends Response {
constructor(url, body, init) {
super(body, init)
Object.defineProperty(this, 'url', {value:url, enumerable:true, configurable:true})
}
}
Or same way on the constructed instance:
const response = new Response(body, init)
Object.defineProperty(response, 'url', {value:url, enumerable:true, configurable:true})
I would suggest doing one or the other to avoid unnecessary incompatibly with regular fetch.
Thanks for the heads up, will do