express-request-ajax-error
request-ajax error handler for express
Install
$ npm install --save express-request-ajax-error
Usage
Below is a example of usage. test/fixture/app.js also have a similar example.
var express = ;var request = ;var requestAjaxError = ; var app = ;app; app;
Logout Callback
If the API returns a 401 code you should logout the user. Provide a logout callback and the module will do it for you.
reslocalsapiError = ;
Thrown Error Object
Variables provided with the error object:
err.url
API url that has caused iterr.status
API HTTP request statusCode
backbone
Backbone.ajax error handler that maps this module according to Backbone.sync. Below is a example of usage.
// one time setupBackboneajax = ; // ... // bind to express requestvar backboneRequestAjaxError = ; // ... // usevar model = ;model;