在我们的 Angular 应用程序中,有时我们会返回 http 状态 -1 给我们。状态 -1 发生在关闭的弹出窗口上,因此用户不会受其影响,只会影响我们的日志。
我试图通过做来处理它
switch (response.status) {
case 0:
break;
case -1:
break;
case 401:
localStorageService.clearAll();
redirectToUrlAfterLogin.url = $location.path();
$location.path('/login');
这是在 AngularJS Issue #12920 中提出的建议
我们的登录确实减少了,但仍然有一些 HTTP -1 状态代码。我应该用不同的方式处理 -1 吗?
最佳答案
当请求被中止或超时时,请求会以状态为 -1 的错误着陆。
Also, status codes less than -1 are normalized to zero. -1 usually means the request was aborted, e.g. using a
config.timeout
.
timeout – {number|Promise}
– timeout in milliseconds, or promise that should abort the request when resolved.
关于angularjs - Angular HTTP : Status -1 and CORS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35418688/