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.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
superagent-intercept
2320.1.26 years ago8 years agoMinified + gzip package size for superagent-intercept in KB

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

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 ...
});