0

Please help me to figure out with CORS on my Ionic2/Angular2 application. I'm trying to get data with http 'GET' request. When I'm running '$npm run build' at laptop, I get an expected response. When I'm running '$ cordova run android', I always get 'Response with status: 0 for URL: null'. Here is the code snippet:

this.http.get('https://httpbin.org/ip')
        .subscribe((data: any) => {
            this.result = data._body; // {"origin": "31.43.103.88"} on laptop
        }, error => {
            this.result = error; // 'Response with status: 0 for URL: null' on android
        });

Thanks.

max
  • 612
  • 7
  • 26
  • Do you manage to reach your ip from a browser ? Verify if port in not blocked by firewall also. If still not working, see this post : http://stackoverflow.com/a/36124935/2549619 – e666 Oct 14 '16 at 20:33

1 Answers1

0

Hmm... It looks like I figured out by myself. I did this: 1) ionic platform rm android 2) ionic platform add android It's weird, but works like a charm.

max
  • 612
  • 7
  • 26