mardi 3 février 2015

How do you properly promisify request?


Bluebird promisifaction is a little magic, and request is quite a mess (it's a function which behaves as an object with methods).


The specific scenario is quite simple: I have a request instance with cookies enabled, via a cookie jar (not using request's global cookie handler). How can I effectively promisify it, and all of the methods it supports?


Ideally, I'd like to be able to:



  • call request(url) -> Promise

  • call request.getAsync(url) -> Promise

  • call request.postAsync(url, {}) -> Promise


It seems as though Promise.promisifyAll(request) is ineffective (as I'm getting "postAsync is not defined").





Aucun commentaire:

Enregistrer un commentaire