{"action":"created","issue":{"url":"https://api.github.com/repos/agmen-hu/node-datapumps/issues/12","labels_url":"https://api.github.com/repos/agmen-hu/node-datapumps/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/agmen-hu/node-datapumps/issues/12/comments","events_url":"https://api.github.com/repos/agmen-hu/node-datapumps/issues/12/events","html_url":"https://github.com/agmen-hu/node-datapumps/issues/12","id":56033542,"number":12,"title":"Does the RestMixin handle responses?","user":{"login":"thxmike","id":2818218,"avatar_url":"https://avatars.githubusercontent.com/u/2818218?v=3","gravatar_id":"","url":"https://api.github.com/users/thxmike","html_url":"https://github.com/thxmike","followers_url":"https://api.github.com/users/thxmike/followers","following_url":"https://api.github.com/users/thxmike/following{/other_user}","gists_url":"https://api.github.com/users/thxmike/gists{/gist_id}","starred_url":"https://api.github.com/users/thxmike/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thxmike/subscriptions","organizations_url":"https://api.github.com/users/thxmike/orgs","repos_url":"https://api.github.com/users/thxmike/repos","events_url":"https://api.github.com/users/thxmike/events{/privacy}","received_events_url":"https://api.github.com/users/thxmike/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-01-30T13:32:40Z","updated_at":"2015-01-31T13:49:59Z","closed_at":null,"body":"I have the following sample code which uses the postJson function. Since this is using Restler, I am wiring up to the events from Restler. However, it appears the events are swallowed, since there appears to be no way to get to the response data. I have also tried this with the post function as well. This is required to get response information for a latter operation.\r\n\r\ndata_pump\r\n        .mixin(datapumps.mixin.RestMixin)\r\n        .process(function (data) {\r\n\r\n            var test_record = <some json>\r\n            var test_record_json = JSON.stringify(test_record);\r\n\r\n            this.postJson('http://qa71-app.mia.ucloud.int/ucc/api/candidates', { \r\n                multipart: false, \r\n                headers: { 'Content-Type' : 'application/json',  'X-ApiKey' : 'xxxxxx'  }, \r\n                data: test_record_json\r\n            }).on('complete', function(data, response) {\r\n                console.log(response.statusCode);\r\n            }).on('error', function(err, response){\r\n                console.log(response.statusCode)\r\n            }).on('fail', function(err, response){\r\n                console.log(response.statusCode)\r\n            }).on('success', function(err, response){\r\n                console.log(response.statusCode)\r\n            }).on('2XX', function(err, response){\r\n                console.log(response.statusCode)\r\n            }).on('3XX', function(err, response){\r\n                console.log(response.statusCode)\r\n            }).on('4XX', function(err, response){\r\n                console.log(response.statusCode)\r\n            }).on('5XX', function(err, response){\r\n                console.log(response.statusCode)\r\n            }).on('end', function(err, response){\r\n                console.log(response.statusCode)\r\n            });\r\n        })\r\n        .start();\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/agmen-hu/node-datapumps/issues/comments/72318397","html_url":"https://github.com/agmen-hu/node-datapumps/issues/12#issuecomment-72318397","issue_url":"https://api.github.com/repos/agmen-hu/node-datapumps/issues/12","id":72318397,"user":{"login":"thxmike","id":2818218,"avatar_url":"https://avatars.githubusercontent.com/u/2818218?v=3","gravatar_id":"","url":"https://api.github.com/users/thxmike","html_url":"https://github.com/thxmike","followers_url":"https://api.github.com/users/thxmike/followers","following_url":"https://api.github.com/users/thxmike/following{/other_user}","gists_url":"https://api.github.com/users/thxmike/gists{/gist_id}","starred_url":"https://api.github.com/users/thxmike/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thxmike/subscriptions","organizations_url":"https://api.github.com/users/thxmike/orgs","repos_url":"https://api.github.com/users/thxmike/repos","events_url":"https://api.github.com/users/thxmike/events{/privacy}","received_events_url":"https://api.github.com/users/thxmike/received_events","type":"User","site_admin":false},"created_at":"2015-01-31T13:49:59Z","updated_at":"2015-01-31T13:49:59Z","body":"OK, I apologize but I am not following. I first tried the following to see if the data I am anticipating is correct:\r\n\r\nthis.postJson(target_service_end_point, { \r\n                multipart: false, \r\n                headers: { 'Content-Type' : 'application/json',  'X-ApiKey' :   'xxxxxx' }, \r\n                data: test_record_json\r\n            }).then(function(responseData) {\r\n\r\n                console.log(responseData);\r\n                console.log(responseData.statusCode);\r\n                this.copy(responseData);\r\n\r\n            }.bind(this));\r\n\r\nI see the response payload, however, I can see the statusCode or header information.\r\n\r\nI then tried based on what you stated about process returning a promise and did the following:\r\nfirst this\r\ndata_pump\r\n        .mixin(datapumps.mixin.RestMixin)\r\n        .process(function (data) {\r\n            var test_record = '<some formatted json>'\r\n            var test_record_json = JSON.stringify(test_record);\r\n\r\n            return this.postJson(target_service_end_point, { \r\n                multipart: false, \r\n                headers: { 'Content-Type' : 'application/json',  'X-ApiKey': 'XXXXXXXX' }, \r\n                data: test_record_json\r\n            }).then(function(responseData) {\r\n                //console.log(responseData);\r\n                //console.log(responseData.statusCode);\r\n                return this.copy(responseData);\r\n            }.bind(this));\r\n          \r\n        }).start().whenFinished().then(function(data){\r\n            console.log(data);\r\n            console.log(data.statusCode);\r\n            console.log(data.headers);\r\n        });\r\nI get nothing in the console\r\n\r\nthen I tried this\r\ndata_pump\r\n        .mixin(datapumps.mixin.RestMixin)\r\n        .process(function (data) {\r\n            var test_record = '<some formatted json>'\r\n            var test_record_json = JSON.stringify(test_record);\r\n\r\n            return this.postJson(target_service_end_point, { \r\n                multipart: false, \r\n                headers: { 'Content-Type' : 'application/json',  'X-ApiKey': 'XXXXXXXX' }, \r\n                data: test_record_json\r\n            }).then(function(responseData) {\r\n                //console.log(responseData);\r\n                //console.log(responseData.statusCode);\r\n                return this.copy(responseData);\r\n            }.bind(this));\r\n          \r\n        }).then(function(data){\r\n            console.log(data);\r\n            console.log(data.statusCode);\r\n            console.log(data.headers);\r\n        }).start(); \r\nERROR\r\n\r\nthen I tried this\r\ndata_pump\r\n        .mixin(datapumps.mixin.RestMixin)\r\n        .process(function (data) {\r\n            var test_record = '<some formatted json>'\r\n            var test_record_json = JSON.stringify(test_record);\r\n\r\n            return this.postJson(target_service_end_point, { \r\n                multipart: false, \r\n                headers: { 'Content-Type' : 'application/json',  'X-ApiKey': 'XXXXXXXX' }, \r\n                data: test_record_json\r\n            }).then(function(responseData) {\r\n                //console.log(responseData);\r\n                //console.log(responseData.statusCode);\r\n                return this.copy(responseData);\r\n            }.bind(this));\r\n          \r\n        }).start().then(function(data){\r\n            console.log(data);\r\n            console.log(data.statusCode);\r\n            console.log(data.headers);\r\n        }); \r\nERROR"}}