https://github.com/codesuki/superagent-intercept
Add functions that will be called during end() e.g. for handling error conditions without having the same code all over the place.
https://github.com/codesuki/superagent-intercept
error-handling intercept interceptor javascript proxy superagent
Last synced: 6 months ago
JSON representation
Add functions that will be called during end() e.g. for handling error conditions without having the same code all over the place.
- Host: GitHub
- URL: https://github.com/codesuki/superagent-intercept
- Owner: codesuki
- License: mit
- Created: 2015-03-04T06:41:23.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-08-15T05:00:21.000Z (about 9 years ago)
- Last Synced: 2025-03-21T03:51:14.629Z (7 months ago)
- Topics: error-handling, intercept, interceptor, javascript, proxy, superagent
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 23
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```javascript
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 ...
});
```