Skip to content
This repository has been archived by the owner on Jun 3, 2020. It is now read-only.

Response returned by experimental.globalFetch should have non empty.url #16

Open
Gozala opened this issue Nov 20, 2018 · 1 comment
Open

Comments

@Gozala
Copy link

Gozala commented Nov 20, 2018

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.

@pfrazee
Copy link
Member

pfrazee commented Nov 20, 2018

Thanks for the heads up, will do

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants