Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/koenpunt/superagent-use
Global plugin support for SuperAgent
https://github.com/koenpunt/superagent-use
middleware superagent
Last synced: 20 days 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 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-31T07:10:40.000Z (almost 7 years ago)
- Last Synced: 2024-10-20T18:21:40.238Z (26 days 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 [![Build Status](https://travis-ci.org/koenpunt/superagent-use.svg?branch=master)](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) {
//
});
```