https://github.com/koenpunt/superagent-use
Global plugin support for SuperAgent
https://github.com/koenpunt/superagent-use
middleware superagent
Last synced: about 1 month ago
JSON representation
Global plugin support for SuperAgent
- Host: GitHub
- URL: https://github.com/koenpunt/superagent-use
- Owner: koenpunt
- License: mit
- Created: 2016-02-25T15:21:06.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-01-31T07:10:40.000Z (over 7 years ago)
- Last Synced: 2024-12-15T02:51:29.476Z (10 months ago)
- Topics: middleware, superagent
- Language: JavaScript
- Size: 5.86 KB
- Stars: 36
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# superagent-use [](https://travis-ci.org/koenpunt/superagent-use)
Global plugin support for [SuperAgent](https://github.com/visionmedia/superagent/).
## Summary
Instead of manually calling `use()` for every request, `use()` is called automatically for every request.
## Example
```js
/* The superagent-use module returns a clone of the superagent provided with the new functionality. */
var agent = require('superagent-use')(require('superagent'));
/* A sample superagent plugin/middleware. */
var prefix = require('superagent-prefix');agent.use(prefix('https://api.example.com'));
agent
.post('/auth')
.send({user: 'foo', pass: 'bar123'})
.on('request', function(req) {
console.log(req.url); // => https://api.example.com/auth
})
.end(function(err, res) {
//
});
```