You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been trying to find the reason I can't properly handle an AJAX error using hyperagent and traced it back to a global configuration setting somebody placed in our project to catch 401s and redirect.
Seems that the configuration option below breaks the promise that Hyperagent sets up, so I'll need to reconfigure that, but it might be nice to allow defining a global error handler that can resolve alongside or bubble up the reject?
If nothing else, might be good to just document this in the README as a potential pitfall - don't set ajax.error in the hyperagent config.
var Resource = require('hyperagent').Resource;
var api = new Resource({
url: 'https://api.example.com/',
ajax: {
error: function(xhr, status, error){
if(status == "error" && xhr.status == 401){ window.location = '/login' }
}
}
});
The text was updated successfully, but these errors were encountered:
In my case, I'm just going to change to using the statusCode: {} config option jquery provides, since that's more appropriate anyway. I'm not even sure how you'd want a global error handler option to act, so I think the better resolution here is just a warning in the README that it is a bad idea and will break the way hyperagent resolves ajax promises.
I've been trying to find the reason I can't properly handle an AJAX error using hyperagent and traced it back to a global configuration setting somebody placed in our project to catch 401s and redirect.
Seems that the configuration option below breaks the promise that Hyperagent sets up, so I'll need to reconfigure that, but it might be nice to allow defining a global error handler that can resolve alongside or bubble up the reject?
If nothing else, might be good to just document this in the README as a potential pitfall - don't set ajax.error in the hyperagent config.
The text was updated successfully, but these errors were encountered: