# Http get request return status 0

**URL:** <https://forum.ionicframework.com/t/http-get-request-return-status-0/22302>\
**Category:** ionic-v1\
**Created:** [May 4, 2015, 10:21am UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302 "2015-05-04T10:21:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![hussainanver52](https://avatars.discourse-cdn.com/v4/letter/h/b5a626/32.png) [@hussainanver52](https://forum.ionicframework.com/u/hussainanver52)\
**Post date:** [May 4, 2015, 10:21am UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302/1 "2015-05-04T10:21:53Z")

</div>

i tried to get dynamic data from a external url using get method in http, it works fine in browser but when i run it from device the get request is not processed and returns status 0. CORS is also enabled. the controller is added below for reference

```
$scope.getData = function() {
        $http.get("http://somedomain")
            .success(function(data) {
                $scope.firstname = data;
                
            })
            .error(function(data, status,headers,config) {
                
      $scope.data = data;
      $scope.status = status;
      $scope.headers = headers;
      $scope.config = config;
            });
    };
```

---

<div class="post-metadata">

**Author:** ![m2m](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/m2m/32/77446_2.png) [@m2m](https://forum.ionicframework.com/u/m2m)\
**Post date:** [May 4, 2015, 10:28am UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302/2 "2015-05-04T10:28:56Z")

</div>

why don’t you show the response, anyway i think it return a promise which you better handle it this way :

```
   var deferred = $q.defer();
      var url = "http://somedomain";
      $resource(url)
        .get(function(data) {
          deferred.resolve(data);
        }, function(response) {
          deferred.reject(response);
        });
      return deferred.promise;
```

---

<div class="post-metadata">

**Author:** ![hussainanver52](https://avatars.discourse-cdn.com/v4/letter/h/b5a626/32.png) [@hussainanver52](https://forum.ionicframework.com/u/hussainanver52)\
**Post date:** [May 4, 2015, 3:14pm UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302/3 "2015-05-04T15:14:31Z")

</div>

I am sorry about not putting the response and thank you very much for the help. even after implementing what you said now i am not getting any output even in browser. the output is

```
status 0
response null
request null
data null
```

---

<div class="post-metadata">

**Author:** ![xvegas](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/xvegas/32/83887_2.png) [@xvegas](https://forum.ionicframework.com/u/xvegas)\
**Post date:** [May 4, 2015, 4:27pm UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302/4 "2015-05-04T16:27:00Z")

</div>

> [@hussainanver52](#):
>
> tried to get dynamic data from a external url using get method in http, it works fine in browser but when i run it from device the get request is not processed and returns status 0. CORS is also enabled. the controller is added below for reference

If is any help,  
First use another servicer URL [https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain](https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain) see if you get data then try your service again and do this,

on your debugger (google dev-tools in my case) check your Network tab to see what is the response what code do you get when the data is requested e.g. code 200 is ok 401 file no found or 500 server error, then if the response is 200 then you should have a break point in before resolve the promise to check o the data retrieve, if the call is successful the break point will stop on the resolve part of the service but the response could be empty, so then check on the sever service.

---

<div class="post-metadata">

**Author:** ![hussainanver52](https://avatars.discourse-cdn.com/v4/letter/h/b5a626/32.png) [@hussainanver52](https://forum.ionicframework.com/u/hussainanver52)\
**Post date:** [May 4, 2015, 7:32pm UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302/5 "2015-05-04T19:32:35Z")

</div>

Thank you very much for the input but same result its working fine in browser but when i run in device the output status 0

---

<div class="post-metadata">

**Author:** ![dany85](https://avatars.discourse-cdn.com/v4/letter/d/7ab992/32.png) [@dany85](https://forum.ionicframework.com/u/dany85)\
**Post date:** [May 4, 2015, 7:53pm UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302/6 "2015-05-04T19:53:05Z")

</div>

i have the same problem. I tried to compile the app with a old ionic version and it works fine. Maybe it is a ionic issue ☹

---

<div class="post-metadata">

**Author:** ![xvegas](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/xvegas/32/83887_2.png) [@xvegas](https://forum.ionicframework.com/u/xvegas)\
**Post date:** [May 4, 2015, 7:58pm UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302/7 "2015-05-04T19:58:39Z")

</div>

It is pretty hard to see the solution without the console errors if you have some screen shoots of the error, and the headers of the service call so we can see the output would be better. now if you don’t have the dev-tools to debug let me know I will point you in the right direction so look into it.

Now i think if any service that you call retrieves cero data, then is a network issue no the service itself, and this could be due to many problems on the network on the phone, but to be sure the info from the debugger is key to solve this puzzle

---

<div class="post-metadata">

**Author:** ![dany85](https://avatars.discourse-cdn.com/v4/letter/d/7ab992/32.png) [@dany85](https://forum.ionicframework.com/u/dany85)\
**Post date:** [May 4, 2015, 7:59pm UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302/8 "2015-05-04T19:59:42Z")

</div>

it is an issue on last release (1.0.0-rc5) released on 2015-04-27

---

<div class="post-metadata">

**Author:** ![xvegas](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/xvegas/32/83887_2.png) [@xvegas](https://forum.ionicframework.com/u/xvegas)\
**Post date:** [May 4, 2015, 8:02pm UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302/9 "2015-05-04T20:02:16Z")

</div>

where may I verify that information do you have a link, because all my services works perfect fine, and I would like to look into it before I mess the services that are working already.

---

<div class="post-metadata">

**Author:** ![hussainanver52](https://avatars.discourse-cdn.com/v4/letter/h/b5a626/32.png) [@hussainanver52](https://forum.ionicframework.com/u/hussainanver52)\
**Post date:** [May 4, 2015, 8:05pm UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302/10 "2015-05-04T20:05:02Z")

</div>

service.js

```
 var all = function() {
        var users = [];
          var deferred = $q.defer();
          var url = "https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain";
          $resource(url)
            .get(function(data) {
                alert(data);
              deferred.resolve(data);
            }, function(response) {
              deferred.reject(response);
               alert("response");
            });
          return deferred.promise;
          };
      return {
        all: all
         
      }

```

controller.js

```
Chats.all().then(function(result) {
         $scope.chats = result;
     });

```

i am not able to debug in mobile device this request is working extremely ok with web browser

---

<div class="post-metadata">

**Author:** ![dany85](https://avatars.discourse-cdn.com/v4/letter/d/7ab992/32.png) [@dany85](https://forum.ionicframework.com/u/dany85)\
**Post date:** [May 4, 2015, 8:07pm UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302/11 "2015-05-04T20:07:23Z")

</div>

Which version are you using?  
If you type ionic -v

---

<div class="post-metadata">

**Author:** ![xvegas](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/xvegas/32/83887_2.png) [@xvegas](https://forum.ionicframework.com/u/xvegas)\
**Post date:** [May 4, 2015, 8:08pm UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302/12 "2015-05-04T20:08:27Z")

</div>

Im using 1.3.20 as my version of ionic I started on this version two weeks o 3 ago

---

<div class="post-metadata">

**Author:** ![xvegas](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/xvegas/32/83887_2.png) [@xvegas](https://forum.ionicframework.com/u/xvegas)\
**Post date:** [May 4, 2015, 8:12pm UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302/13 "2015-05-04T20:12:08Z")

</div>

ok let me do a plunker that works for you and if still not getting data then you need to debug with a device and use the google developer tools to gather more info about the issue.

---

<div class="post-metadata">

**Author:** ![hussainanver52](https://avatars.discourse-cdn.com/v4/letter/h/b5a626/32.png) [@hussainanver52](https://forum.ionicframework.com/u/hussainanver52)\
**Post date:** [May 4, 2015, 8:13pm UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302/14 "2015-05-04T20:13:16Z")

</div>

my version is 1.3.20

---

<div class="post-metadata">

**Author:** ![dany85](https://avatars.discourse-cdn.com/v4/letter/d/7ab992/32.png) [@dany85](https://forum.ionicframework.com/u/dany85)\
**Post date:** [May 4, 2015, 8:24pm UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302/15 "2015-05-04T20:24:10Z")

</div>

i have a same project … if i run it on ionic 1.3.22 it doesn’t works, if i run with an old version (1.2.8) it works fine

---

<div class="post-metadata">

**Author:** ![xvegas](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/xvegas/32/83887_2.png) [@xvegas](https://forum.ionicframework.com/u/xvegas)\
**Post date:** [May 4, 2015, 8:31pm UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302/16 "2015-05-04T20:31:44Z")

</div>

ok I made a sample for you I hope this helps

[http://plnkr.co/edit/m74z5IbvBqBviH0IbLqe?p=preview](http://plnkr.co/edit/m74z5IbvBqBviH0IbLqe?p=preview)

on the picture you will see data on the right hand side thats is proof the service is working and being displaying data on the html from the service

 ![image](https://global.discourse-cdn.com/ionicframework/original/2X/f/ff9f17201e63cd8ccf87b85ec3fa4444cc788d17.png)

---

<div class="post-metadata">

**Author:** ![dany85](https://avatars.discourse-cdn.com/v4/letter/d/7ab992/32.png) [@dany85](https://forum.ionicframework.com/u/dany85)\
**Post date:** [May 4, 2015, 8:39pm UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302/17 "2015-05-04T20:39:45Z")

</div>

yes the problem is that on devide (android it doesn’t works)

---

<div class="post-metadata">

**Author:** ![hussainanver52](https://avatars.discourse-cdn.com/v4/letter/h/b5a626/32.png) [@hussainanver52](https://forum.ionicframework.com/u/hussainanver52)\
**Post date:** [May 4, 2015, 8:42pm UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302/18 "2015-05-04T20:42:18Z")

</div>

Thank you for the updated code but still its not working in device. same as early

---

<div class="post-metadata">

**Author:** ![xvegas](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/xvegas/32/83887_2.png) [@xvegas](https://forum.ionicframework.com/u/xvegas)\
**Post date:** [May 4, 2015, 8:43pm UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302/19 "2015-05-04T20:43:27Z")

</div>

I’m running my app in android what kind of device and api are you using and remember to debug you need a device with 4.4 android version at lease and API 19 otherwise is impossible to debug .

---

<div class="post-metadata">

**Author:** ![hussainanver52](https://avatars.discourse-cdn.com/v4/letter/h/b5a626/32.png) [@hussainanver52](https://forum.ionicframework.com/u/hussainanver52)\
**Post date:** [May 4, 2015, 8:48pm UTC](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302/20 "2015-05-04T20:48:01Z")

</div>

i am using 4.2 android but when i run url in debug console none of the request are displaying

[Next page](https://forum.ionicframework.com/t/http-get-request-return-status-0/22302.md?page=2)
