从AngularJS$http.post捕获中获取失败原因



我有如下内容:

$http.post('http://some.url/', {service: "/", path: "/"})
.then(function (result) {
console.log(result);
deferred.resolve(result);
})
.catch(function (error) {
console.log(error);
deferred.reject(error);
});

在捕获的内部,我正在记录错误,并得到如下内容:

{
config: {
data: {service: "/", path: "/"},
headers: {Accept: "application/json, text/plain, */*", Content-Type: "application/json;charset=utf-8"},
jsonpCallbackParam: "callback",
method: "POST",
paramSerializer: ƒ (e),
transformRequest: [ƒ],
transformResponse: [ƒ],
url: "http://some.url/"
},
data: null,
headers: ƒ (n),
status: -1,
statusText: "",
xhrStatus: "error",
}

有没有什么方法可以让我得到错误的实际原因(比如net::ERR_FAILED或net::error_NAME_NOT_RESOLVED或其他什么(?我的一些用户的呼叫失败了,我没有足够的信息来找出原因。

看起来我无法获得这些信息-此故障是由https://github.com/angular/angular.js/blob/26a5779cddf70944b7548e3a6410d35237a516e5/src/ng/httpBackend.js,分配给xhr.onerror

xhr.onerror不会给出任何关于失败的具体细节(Chrome似乎不符合要求,因为它给了oneror一个ProgressEvent类型的参数,但它仍然没有有用的数据(。

最新更新