Skip to content
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

Create XMLHttpRequest Capturing polyfill #5

Closed
morsdyce opened this issue Nov 28, 2015 · 3 comments
Closed

Create XMLHttpRequest Capturing polyfill #5

morsdyce opened this issue Nov 28, 2015 · 3 comments
Milestone

Comments

@morsdyce
Copy link
Owner

No description provided.

@morsdyce morsdyce added this to the Beta milestone Nov 28, 2015
@alexilyaev
Copy link
Contributor

Why Polyfill? I think that this would work if it's loaded before Angular (or whatever library):
http://stackoverflow.com/questions/629671/how-can-i-intercept-xmlhttprequests-from-a-greasemonkey-script

@morsdyce
Copy link
Owner Author

Because we need to modify the response, we don't need to polyfill the entire API, just the parts we need.

@ilyagelman is currently investigating this

@ilyagelman
Copy link
Contributor

So I found this package: https://github.com/jpillora/xhook

xhook.before((request) => {
  if (request.url.match('/users')) {
    return { status: 200, data: { a: 1 } }
  }
});

It also has can be easily disabled with xhook.disable()

It does not support fetch() though, but we can use it for v1 just to make things up and running.

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

No branches or pull requests

3 participants