Http error incomplete_chunked_encoding in Ionic

Hi everybody,
I using angularjs $Http to Subscribe Meshblu api, but it was return error "incomplete_chunked_encoding"
This is my code:
function sendUrl(method, url, uuid, token, requestData) {
return $q(function (resolve, reject) {
$http({
method: method,
url: url,
headers: {
“Content-Type”: “application/json”,
“meshblu_auth_uuid”: uuid,
“meshblu_auth_token”: token
},
data: requestData,
dataType: “json”
}).then(function (res) {
if (res.data != null) {
console.log('ServerMeshbluData ’ + 'sendUrl ’ + url + ‘\n’ + JSON.stringify(res.data));
resolve(res.data);
} else {
console.log('ServerMeshbluData ’ + 'sendUrl ’ + url + ‘\n’ + JSON.stringify(res.data));
resolve(res.data);
}
}, function (err) {
console.log('ServerMeshbluData ’ + 'sendUrl ’ + url + ‘\n’ + JSON.stringify(err));
reject(err);
});
});
}

Can anyone help me!

Thanks.

what version of angularjs are you using?

I’m using:
Ionic: "driftyco/ionic-bower#1.3.2"
AngularJS v1.5.3

Do you have any idea about that? Please help me.

Please post the code you have in your service and controller and the view to see if everything is correct.

Hi Mr Amad4biz,
This is code in my service:
angular.module(‘dialog’)
.factory(‘ServerMeshbluData’, function ($http, $q) {

// API for Meshblu
var mAddress = '192.168.105.95';
var mPort = 9630;
var mDEFAULT_URL = "http://" + mAddress + ":" + mPort;
var mUSER_ID = "PUBLIC";

return {
    sendMsgToMeshblu: function (uuid, token, requestData) {
        return sendUrl('POST', mDEFAULT_URL + '/messages', uuid, token, requestData);
    },

    subscribleMeshblu: function (uuid, token) {
        return $q(function (resolve, reject) {
            $http({
                method: 'GET',
                url: mDEFAULT_URL + '/subscribe',
                headers: {
                    "meshblu_auth_uuid": uuid,
                    "meshblu_auth_token": token
                }
            }).then(function (res) {
                if (res.data != null) {
                    console.log('ServerMeshbluData ' + '\n' + JSON.stringify(res.data));
                    resolve(res.data);
                } else {
                    console.log('ServerMeshbluData ' + '\n' + JSON.stringify(res.data));
                    resolve(res.data);
                }
            }, function (err) {
                console.log('ServerMeshbluData ' + '\n' + JSON.stringify(err));
                reject(err);
            });
        });
    }
}

});

This is in Controller:
angular.module(‘dialog’)
.controller(‘mainCtrl’, function ($scope, ServerMeshbluData) {
document.addEventListener(“deviceready”, function () {

    /*** Meshblu API ****/
    $scope.uuidSubscribe = "792d6f95-92a7-4bf8-8fd5-4eaefaf20221";
    $scope.tokenSubscribe = "a8d559cf3066b5b535b2ab057a78d8e79a1e3bd5";


    $scope.subscribeMeshblu = function () {
        console.log("start subscribe Meshblu, uuid = " + $scope.uuidSubscribe, ", token = " + $scope.tokenSubscribe);
        ServerMeshbluData.subscribleMeshblu($scope.uuidSubscribe, $scope.tokenSubscribe).then(function (respone) {
            console.log("respone subscribe = " + respone);

            console.log("respone subscribe = " + respone.devices);
            alert(respone);

            // I want to get data and process here

        }).catch(function (error) {
            console.debug("Error subscribe to Meshblu: " + error);
        }).finally(function () {
        });
    }
    
    $scope.subscribeMeshblu();

});