【发布时间】:2014-12-13 14:27:50
【问题描述】:
我正在通过 websockets 执行 $http.get 并且不知何故 .error 没有填充任何参数。我在 OSX 上使用 angular 1.3.5 和最新的 Chrome,本地主机别名为 mywebsite.com。
$http({method: 'GET', 'ws://mywebsite.com/resource'})
.success(function(response){ ... })
.error(function(err, status){
console.log(err); <<< here err and status are null respectively 0 even the XHR Response logs 401 in console.
});
任何线索为什么这样做?无论它是什么错误代码,它都不会传递给错误回调。对于 2xx 响应,我确实得到了数据,一切都很好。
澄清一下,.error 回调会正常调用,但不会填充 err 和 status。
【问题讨论】:
-
是错字吗?你放了两个点
headers}). .success -
抱歉从真实代码中复制粘贴了我的 headers 变量
-
如果您尝试使用
http请求而不是ws,您会收到回调吗?
标签: angularjs