3

I got that issue on my cordova project, created with angular and ionic. I've tried everything I could, and it ain't working.

Here's the code :

    function getSuccess(response) {
    $scope.modules = response.modules;
    $scope.list = $scope.modules;
    $scope.search = [
        {str: ""}
    ];
}

$http({method: 'GET',
        url: "http://xxx.xxx.xxx.xxx/api/modules"
    })
    .success(getSuccess)
    .error(function (response){
        alert("Damned");
    });

Of course, the IP is valid, and works in the chrome browser ;) That's in my controller. I already added <access origin="*"/> in my config file and it's still displays the "Damned" on my android device, after building.

Cordova version : 5.0.0 Android version : 5.1

11
  • response should contain details about the error. don't output a fixed(useless) error message when you can be told exactly what's wrong.
    – Marc B
    Commented May 25, 2015 at 20:34
  • I actually wanted to use something like console.log, but i don't know how to do that in the application, any idea ? :/ Commented May 25, 2015 at 20:37
  • even something like alert(JSON.stringify(response)) could help. anything to get the contents of the error object out and viewable.
    – Marc B
    Commented May 25, 2015 at 20:39
  • 3
    install whitelist plugin cordova-plugin-whitelist (and I don't mess up with the ZOHANNNN)
    – aorfevre
    Commented May 25, 2015 at 20:56
  • 1
    @aorfevre post your comment as an answer, i'll put +1000 at it. You just save my life ! Tyvm ! <3 Commented Jun 2, 2015 at 16:48

1 Answer 1

5

install whitelist plugin : cordova-plugin-whitelist

Since Cordova 5.0.0, Whitelist plugin is mandatory for cross origin requests

Not the answer you're looking for? Browse other questions tagged or ask your own question.