Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

fetch api is not being intercepted by zones #108

Closed
IgorMinar opened this issue May 15, 2015 · 4 comments · Fixed by #119
Closed

fetch api is not being intercepted by zones #108

IgorMinar opened this issue May 15, 2015 · 4 comments · Fixed by #119

Comments

@IgorMinar
Copy link
Contributor

https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API

example usage:

fetch('foo.json').then(function(response) { return response.json() });
@vicb
Copy link
Contributor

vicb commented May 15, 2015

It should be as it returns a Promise.

@vicb
Copy link
Contributor

vicb commented May 15, 2015

Just submitted #112 to check what browsers need a patch.

Would be interesting to know if the browsers are supposed to return a new global.Promise() (ie is it a browser bug ?). Otherwise we'll probably need to patch more than fetch: Response.text() and the like

@vicb
Copy link
Contributor

vicb commented May 15, 2015

@IgorMinar from my tests the issue seems to be that fetch() does not instantiate a window.Promise but a (derived of) Promise.

That means that our monkey patch on window.Promise is not taken into account. This also means that would probably should patch all functions that returns a Promise.

Is this possible for you to check with the Chrome team if that's the current behavior is the desired one ?

vicb added a commit to vicb/zone.js that referenced this issue May 20, 2015
@vicb vicb closed this as completed in #119 May 20, 2015
@radotzki
Copy link

This bug is reproducible from zone.js 0.6.0.
My workaround:

return new Promise((resolve, reject) => {
  return window
    .fetch(url, fetchOptions)
    .then((response) => resolve(response.json()));
});

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

Successfully merging a pull request may close this issue.

3 participants