【发布时间】:2014-08-18 17:24:48
【问题描述】:
使用 Restangular,get 方法/promise 解决,但传递给 .then() 的结果是空的...使用 console.log(data);显示未定义。我在 chromium 调试中检查了网络选项卡,xhr 请求很好,成功了 200 次……正文中有完整的 json 响应。
使用addResponseInterceptor,我发现数据参数未定义,但响应参数显示包含有效负载/正文的数据属性的对象。
所以,我摸不着头脑.....为什么在响应对象正确包含 response.data 中的 json 有效负载/响应时数据参数未定义?
我需要解决这个问题,以便在解决时将结果传递给 .then()。
createNode: function(node) {
var account = "9936";
var eventId = "0fd6afd9-4aa0-a5c9-ff0b3e60cdcf";
Restangular.addResponseInterceptor(function(data, operation, what, url, response, deferred) {
console.log("````````````````");
console.log(data);
console.log(operation);
console.log(what);
console.log(url);
console.log(response);
console.log(deferred);
console.log("````````````````");
});
node.js:12
undefined node.js:13
get node.js:14
event node.js:15
/1.0/loadbalancers/account/9936/event/0fd6afd9-4aa0-a5c9-ff0b3e60cdcf node.js:16
^Object {data: Object, status: 200, headers: function, config: Object}
config: Object
data: Object
Automation: Object
Classification: Array[2]
ExecutionTimestamp: "2014-08-13T16:08:37.4676Z"
ID: "0fd6afd9-a5c9-ff0b3e60cdcf"
Incident: Object
LastStatus: "ENQUEUED"
Metadata: Object
Name: "Node Create"
RecordLogs: false
Source: "Device Lifecycle"
Stream: Object
Targets: Array[1]
【问题讨论】:
标签: angularjs restangular