$http works on browser and not android device

Asked

Viewed 813 times

0

I have an application developed using Ionic Framework, is a hybridized application and we tested done in the browser worked perfectly when I generated the file . apk and tested both in emulator and on the device is not executing the request. the function that is generating error is:

$http.get('http://apps.widenet.com.br/busca-cep/api/cep.json?code='+cep)
    .success(function(data, status, headers, config) {
      if(data.status == 1){
          $scope.respostas[0] = data;
        }
        else if (data.status == 0) {
          $scope.hasErros = true;
          $scope.erro = data.message;
        }
    })
    .error(function(data, status, headers, config) {
      $scope.hasErros = true;
      $scope.erro = "Um erro inexperado ocorreu!";
    });
  }
})

This is the function that executes the request to the server, however it only falls into the part:

.error(function(data, status, headers, config) {
          $scope.hasErros = true;
          $scope.erro = "Um erro inexperado ocorreu!";
        });

and always displays the message "An inexperienced error occurred!", when run by device, when run by a browser always right, someone knows how to help me ?

  • I have the same problem the origin acess this as you had informed and does not work

2 answers

0


Colleague, manage a debug apk ( ionic run android ) and plug your phone via USB enabling the modo de depuração USB on your device. Then open the Chrome console on developers tools and debug the app.

0

Add the option below in the config.xml file:

access origin="*"

example

If it already exists, remove the values inside for origin and add the *.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.