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

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.

Have you added whitelist plugin ?

ionic plugin add cordova-plugin-whitelist

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