Wraps superagent requests in ES6 promises (see the es6 promises polyfill and mdn for W3C Promise API documentation).
e.g
require('superagent')
.get('http://api.mysite.com/?id=23432')
.use(require('superagent-promises'))
.end()
.then(function (response) {
// handle a successful response
}, function (err) {
// handle an error
})
superagent-promises caches the native .end()
method of superagent. For testing purposes an .uncache()
method is provided, which should be called immediately before spying or stubbing superagent.end()