[AC-1049] Mobile to ACS Bindings not working as in docs?
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Resolved |
Resolution | Cannot Reproduce |
Resolution Date | 2015-09-15T03:58:32.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | TCSupportTriage |
Reporter | Manuel Conde Vendrell |
Assignee | Shak Hossain |
Created | 2014-08-08T14:53:40.000+0000 |
Updated | 2016-03-08T07:37:23.000+0000 |
Description
In this docs about ACS bindings, the example is:
http://docs.appcelerator.com/cloud/latest/#!/guide/node_studio_integrated
var cloud_service = require('ti.cloud.FooBar');)
// The default generated bindings file allows you to send payload data and a success callback.
cloud_service.application_createFoo({'foo':'foobar'}, function(r, e){
Ti.API.info(JSON.stringify(r));
});
It's supposed that the *r* parameter is the awaited response.
In my experience today, I only receive the data in the *second e* parameter, having *r* only null.
Viewing the code generated by Studio, maybe is there something wrong:
function InvokeService(path, method, data, cb) {
if (typeof(data) == "function") {
cb = data; data = null;
}
if (typeof(cb) !== "function")
throw new Error("callback must be provided!");
var xhr = Ti.Network.createHTTPClient();
xhr.onerror = function(e) {
cb(e.error);
};
xhr.onload = function(e) {
var r = this.responseText;
try {
if (xhr.getResponseHeader("content-type").indexOf("json") != -1) {
r = JSON.parse(r);
}
} catch (E) {}
cb(null, r);
};
if(exports.URL.match('/$') == '/' && path.indexOf('/') == 0) {
xhr.open(method, exports.URL + path.substring(1));
} else {
xhr.open(method, exports.URL + path);
}
xhr.send(data);
};
The line in the returned function *xhr.onload* is *cb(null, r);*, i.e., will return null for first parameter and r for second (as I'm viewing by my self in my test).
It is an error in the Invoke function code, in the docs, or what?
Hello, We are unable to reproduce the reported error. Please Migrate your Node.ACS Application to Arrow Cloud. Migration link: https://web.appcelerator.com/product/migrate-app#node_acs_instructions Additionally, I recommend you to upgrade your studio and SDK to the latest build and test that code then let us know if you get the error again. Thanks.