Skip to content

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

License

Notifications You must be signed in to change notification settings

codesuki/superagent-intercept

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published