JavaScript IBMCloudCodeHybrid SDK always going to onFailure on Android

I am developing a mobile hybrid application on BlueMix. I have just added the necessary tools by following the instructions here.

Server Node.js code (dependencies and ibmconfig variable are correctly set):

app.get(ibmconfig.getContextRoot() + '/hello', function(req,res){
    res.send('World');
});


Hybrid mobile application code:

var setup = {
    applicationId:'<applicationId>',
    applicationRoute:'<applicationRoute>',
    applicationSecret:'<applicationSecret>'
};

IBMBluemix.initialize(setup).then(function(config){
    return IBMCloudCode.initializeService();
}).then(function(cloudcode){
    cloudcode.get("/hello").then(function(data){
        alert(data);
    }, function(err){
        alert("[ERROR] " + err);
    });
});

Sorry for removing all none necessary stuff. My issue is that this code is actually working on iOS devices, but not on Android. Meaning for iOS I get the World alert, but for Android I get [ERROR] "{\"code\":200,\"data\":\"World\"}" alert. And whatever I try to do (for instance setting the content-type header), I always go to the onFailure function on Android devices.

What I found out is that the server response on Android is understood as a string and not a JSON, so I changed the IBMCloudCodeHybrid.js:line 687 and added

if (response.constructor === 'abc'.constructor) {
      response = JSON.parse(response);
}
if (_.has(response, "code") && _.has(response, "data") && response.code === 200) {
      response = response.data;
} else {
      defer.reject(response);
}

so that whenever a string is received, it will be converted to JSON.
And that worked for me.
So my questions are, do I have to that in order to make it work on Android? Or is there a proper way to do that/I am doing something wrong ? Or is something wrong with the Bluemix SDK ?

Answer:1

Is there a way to create a custom animation event with angularJS. I am trying to create my own event of trigger an event on my own. I'd like to do the following <div ng-animate="{myEvent: 'my-...

Is there a way to create a custom animation event with angularJS. I am trying to create my own event of trigger an event on my own. I'd like to do the following <div ng-animate="{myEvent: 'my-...

I have this code in JQUERY: var large='<div class="vip" style ="background:url(./uploads/deal/"+data[a].id+"_1.jpg);"> <span class ="coundtown" value ='+data[a].deal_time_off+' ...

I have this code in JQUERY: var large='<div class="vip" style ="background:url(./uploads/deal/"+data[a].id+"_1.jpg);"> <span class ="coundtown" value ='+data[a].deal_time_off+' ...

  1. uncaught syntaxerror unexpected token ' '
  2. uncaught syntaxerror unexpected identifier
  3. uncaught syntaxerror unexpected end of input
  4. uncaught syntaxerror unexpected token 'export'
  5. uncaught syntaxerror unexpected end of json input
  6. uncaught syntaxerror unexpected token ' ' react
  7. uncaught syntaxerror unexpected token in json at position 0
  8. uncaught syntaxerror unexpected string
  9. uncaught syntaxerror unexpected token ' ' angular
  10. uncaught syntaxerror unexpected identifier javascript
  11. uncaught syntaxerror unexpected token 'else'
  12. uncaught syntaxerror unexpected number
  13. uncaught syntaxerror unexpected token 'if'
  14. uncaught syntaxerror unexpected token javascript
  15. uncaught syntaxerror unexpected token 'var'
  16. uncaught syntaxerror unexpected token 'function'
  17. uncaught syntaxerror unexpected token 'export' popper.js
  18. uncaught syntaxerror unexpected reserved word
  19. uncaught syntaxerror unexpected token '.' css
  20. uncaught syntaxerror unexpected identifier jquery

I have implemented Login with Facebook successfully and now trying to implement logout option. Included script https://connect.facebook.net/en_US/all.js Invoked JavaScript FB.logout(); as per https:/...

I have implemented Login with Facebook successfully and now trying to implement logout option. Included script https://connect.facebook.net/en_US/all.js Invoked JavaScript FB.logout(); as per https:/...

Trying to make a progress bar for a form upload (old HTML4 form upload, not new HTML5 API). The progress actually tracks additional work being done after the file has moved. The way it has been ...

Trying to make a progress bar for a form upload (old HTML4 form upload, not new HTML5 API). The progress actually tracks additional work being done after the file has moved. The way it has been ...

  1. ajax form upload file
  2. ajax form upload image
  3. ajax form upload
  4. ajax form upload file mvc
  5. ajax form upload progress
  6. ajax upload form data
  7. ajax upload form php
  8. ajax form file upload php
  9. jquery ajax form upload
  10. jquery ajax form upload file
  11. ajax form submit upload file
  12. jquery ajax form upload image
  13. ajax beginform file upload
  14. ajax form serialize file upload
  15. ajax form data file upload
  16. ajax form submit image upload
  17. ajax form data image upload
  18. ajax form multiple file upload
  19. ajax form post file upload
  20. ajax file upload form using jquery