$ http works in browser and not in android device [closed]

0

I have an application developed using Ionic Framework , it is a hybrid application and in the tests done in the browser it worked perfectly, when I generated the .apk file and tested both the emulator and 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 in the part:

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

    

asked by anonymous 25.05.2015 / 00:13

2 answers

0

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

    
30.11.2015 / 19:12
0

Add the following option to the config.xml file:

access origin="*"

example        

If it already exists remove the values inside the source and add the *.

    
20.05.2016 / 20:18