KyleAMathews / superagent-bluebird-promise

Add promise support to superagent using Bluebird
MIT License
182 stars 37 forks source link

What are the advantages of using superagent-bluebird-promise? #41

Closed nareshbhatia closed 8 years ago

nareshbhatia commented 9 years ago

I just came across this library. From the README.md, it was not clear to me what would be the advantages of using it over promisifying the superagent library directly:

var request = require('superagent');
var Promise = require('bluebird');
Promise.promisifyAll(request);

The only difference I can see is that I would have to use request.endSync() to get a promise back, which is not a great justification for adding one more dependency to my projects. Am I missing something really obvious?

nickclaw commented 8 years ago

Had you tried that you'd see that it doesn't actually work. Promisifying the request object would give you a few functions, like getAsync(url, query), postAsync(url, body), etc.. but not functionality like request.get(url).set(headers).endAsync() or cancelable promises.

nareshbhatia commented 8 years ago

Since I posted this issue, I went ahead and tried promisifying superagent directly. The following is working without any issues:

return request
    .get(url)
    .set('authorization', authHeader)
    .endAsync()
    .then(function(res) {
        return res.body;
    });

So I am still not clear as to what superagent-bluebird-promise will buy me. BTW, I don't have a use case for cancelable promises.

markdalgleish commented 8 years ago

Cancellable request promises was the main reason I started using this library, which wouldn't work with your snippet. Closing this as it's not actually an issue with the library.