-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add simultaneous promise and callback support #523
Comments
+1 For example, see how they added promise support to AWS node library: |
See also MongoDBs node driver. It very nicely supports both callbacks and promises in the same driver. |
It's incredibly confusing that the "JavaScript client library" supports promises but this library doesn't. How can progress be made on this? We have |
Seems like Google doesn't love NodeJs/Javascript 💔💔💔 |
Googles Docs recommend using promises but I cannot find how to use them with this library |
+1 |
So this ticket is nearly two years old and hasn't had any dev response in that entire time ... does that mean it's dead? If not, Node's I would be happy to submit a PR that simply calls |
Nope, just slow moving :) This project is largely maintained by volunteers on free time, so sometimes stuff like this can take a while. We still very much want to do it, but a few things need to happen first. In the meantime - you can use tools like pify today to promisify the API pretty easily. We also love PRs :) |
As I said (in an edit, so you might have missed it) I'd be happy to submit one, but only if it will actually be used. I certainly wouldn't want to go through and |
Apologies! I did miss the edit. I don't think we want to run through and We already went through the painful process in #891 of swapping out from The work here is to introduce a similar pattern. We need function overloads for public methods that support both the callback and promise based workflows. Famous last words... but I think we've already done most of the heavy lifting here :) I would be ecstatic to review a PR that takes this approach! |
Ugh. My apologies but I'm afraid I have to rescind my offer of a PR, as I'm really not a fan of TypeScript. I do hope someone else will pick up the task though, as I would ❤️ being able to use this library with |
Would something as simple as this work? Basically return the called request functions (which already have conditional promise support) and remove the call to normalize the callback function. I was just playing around with this quickly on my local but it seemed to work for the couple of apis I'm using. I can send a PR with some tests if this seems like the right direction. |
@acoll Thanks a lot for that I adapted it for my own use. |
Well that was a lot of work. Nice job. |
There is an issue with how this was implemented. Before the APIs returned a stream and now they don't. Which means some examples on the online document are broken (like here, first Node exemple). What is more, in this use case, we want to download a file. It might weight Gbs or even Tbs. Using a promise that waits until the request completes (or a callback for that matter) means it will load the whole file in RAM. This is totally unacceptable right?! I want to pipe the request in something and be rid of it! It would be great to return a proxy instead of the actual axios promise. It could accept to act like a stream or like a promise depending on how it's used! |
The other solution would be to expose the |
Ok, reading the code I found out it is indeed exposed as the second parameter... |
No description provided.
The text was updated successfully, but these errors were encountered: