Cordova app doesn't get data from webservice on device but works in the emulator


#1

Hello I’ve built a Cordova application which gets data from an Angular webservice like this:

var req = {
    method: 'POST',
    url: 'http://mywebservice.com',
    headers: {
        'Content-Type': 'application/json; charset=utf-8'
    },
    data: { data},
    crossDomain: true
};

$http(req).

    success(function(data, status, headers, config) {

        callback(data);
    }).

    error(function(data, status, headers, config) {
        console.log("error: "+JSON.stringify(status));
});

So I don’t understand why I’m getting no data shown if everything works perfectly in the browser.


#2

Have you added whitelist plugin ?

ionic plugin add cordova-plugin-whitelist

#3

That’s great! Now its working …Thanks for the update !!