superagent-intercept

0.1.2 • Public • Published

superagent-intercept

Add interceptors that will be called during end() e.g. for handling error conditions without having the same code all over the place.

Support

Please consider supporting the project by starring it on GitHub :)

https://github.com/codesuki/superagent-intercept

Install

npm install superagent-intercept

Example

let AuthIntercept = require('superagent-intercept')((err, res) => {
    if (res.status == 401) {
       // route to login
    }
});
 
request.get('/api/something/' + someId).use(AuthIntercept).end((err, res) {
    // AuthIntercept will be called here.
    // ... code ...
});

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.2
    812
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.2
    812
  • 0.1.1
    627
  • 0.1.0
    1

Package Sidebar

Install

npm i superagent-intercept

Weekly Downloads

1,440

Version

0.1.2

License

MIT

Last publish

Collaborators

  • codesuki