superagent-use

0.1.0 • Public • Published

superagent-use Build Status

Global plugin support for SuperAgent.

Summary

Instead of manually calling use() for every request, use() is called automatically for every request.

Example

/* 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) {
    //
  });

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.0
    6,025
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.0
    6,025
  • 0.0.1
    189

Package Sidebar

Install

npm i superagent-use

Weekly Downloads

6,214

Version

0.1.0

License

MIT

Last publish

Collaborators

  • koenpunt