question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: Custom Promise constructor

See original GitHub issue

Allow defining a Promise constructor instead of using globals. The current implementation requires using polyfills that use globals.

Example

axios.defaults.promise = PromisePolyfill;
axios.get('/foo');

or

var axios_instance = axios.create({
  promise: PromisePolyfill
});

axios_instance.get('/foo');

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
jvmccarthycommented, Aug 10, 2016

Hi @rubennorte, funny that I was working on a PR at the same time you were closing this issue. I’m glad to see that promises are now a native feature, but I still think there are reasons for making promises pluggable.

Thank you and the team for your work on axios and for your consideration.

4reactions
Morgulcommented, Apr 21, 2016

+1 Here’s my use case: I use Bluebird on the server side. I also want to use axios on the server side for accessing some external REST APIs. However, since I’m on node 5, axios returns promises that work with the default Promise implementation, and I have to wrap them whenever I want to use .map or the like, which is common.

My choices are to either patch the global Promise, or tell axios which promise library to use. I’d rather do the latter.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Promise() constructor - JavaScript - MDN Web Docs
The Promise() constructor is primarily used to wrap functions that do not already support promises.
Read more >
Resolve Javascript Promise outside the Promise constructor ...
I think there should be a formal way to achieve this in the future. This feature is very powerful in my opinion as...
Read more >
Build a JavaScript Promise | Skilled.dev
Your constructor will take a function as an argument that will resolve or reject the async function request new PromiseSimple((resolve, reject) => {})...
Read more >
Promise() constructor - JavaScript
A function to be executed by the constructor, during the process of constructing the promiseObj . The executor is custom code that ties...
Read more >
Learn JavaScript Promises by Building a Custom ...
js. Callback functions. It would be impractical if making an HTTP request blocked the code until we got a response. Even if it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found