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

Use with Angular.js - clashing Promise implementations #227

Closed
seanoshea opened this issue Sep 25, 2017 · 3 comments
Closed

Use with Angular.js - clashing Promise implementations #227

seanoshea opened this issue Sep 25, 2017 · 3 comments

Comments

@seanoshea
Copy link

I'm trying to use the 4.2.2 version of request-promise in an Angular 4 app. I've developed an in-house networking library for making API calls which is based off request-promise. I'm distributing my library as an internal node module which allows me to load it like:

import my_lib from 'my_lib';

My package.json looks like:

"dependencies": {
    "request": "^2.81.0",
    "request-promise": "^4.2.1"
  }

but I get the following exception when I try to use it:

_Unhandled promise rejection Error: Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.
Most likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)

This might be more of a feature request rather than a bug, but is there any way to have request-promise check for window.Promise before trying to load the Bluebird polyfill?

@seanoshea
Copy link
Author

Wondering if angular/zone.js#899 will take care of this?

@analog-nico
Copy link
Member

Hi @seanoshea , bluebird within request-promise does not act as a polyfill. That means it leaves the global Promise untouched. Your error must have been caused by something else.

Btw, if you prefer to use a different promise implementation even for request-promise itself, you may look into request-promise-native and request-promise-any.

@seanoshea
Copy link
Author

angular/zone.js#899 did not take care of this. Getting:

zone.js:634 Uncaught TypeError: NativePromise.resolve is not a function

now.

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

2 participants