Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1049] Mobile to ACS Bindings not working as in docs?

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionCannot Reproduce
Resolution Date2015-09-15T03:58:32.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
LabelsTCSupportTriage
ReporterManuel Conde Vendrell
AssigneeShak Hossain
Created2014-08-08T14:53:40.000+0000
Updated2016-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?

Comments

  1. Motiur Rahman 2015-09-08

    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.

JSON Source