# $http.get not working

**URL:** <https://forum.ionicframework.com/t/http-get-not-working/3242>\
**Category:** ionic-v1\
**Created:** [April 21, 2014, 7:05pm UTC](https://forum.ionicframework.com/t/http-get-not-working/3242 "2014-04-21T19:05:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adrien](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@Adrien](https://forum.ionicframework.com/u/Adrien)\
**Post date:** [April 21, 2014, 7:05pm UTC](https://forum.ionicframework.com/t/http-get-not-working/3242/1 "2014-04-21T19:05:59Z")

</div>

Attempting to get some json from the backend. Get an http code of 200, followed by 404. I’ve verified the backend is working and returning the json. The backend is Rails 4.0.4, and is using ETags. Here is my code:

.factory(‘People’, function($http) {  
var people = [];

$http.get(‘[http://localhost:3000/people](http://localhost:3000/people)’)  
.success(function(data, status, headers, config){  
people = result.data;  
console.log(data);  
})  
.error(function(data, status, headers, config){  
console.log(data);  
console.log(status);  
});

return {  
all: function() {  
return people;  
}  
}  
})

.controller(‘myapp’, function($scope, People) {

$scope.people = People.all;

});

---

<div class="post-metadata">

**Author:** ![aaronksaunders](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/aaronksaunders/32/13729_2.png) [@aaronksaunders](https://forum.ionicframework.com/u/aaronksaunders)\
**Post date:** [April 21, 2014, 7:27pm UTC](https://forum.ionicframework.com/t/http-get-not-working/3242/2 "2014-04-21T19:27:34Z")

</div>

seems more like a straight angular question? you might want to try stackoverflow

---

<div class="post-metadata">

**Author:** ![Adrien](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@Adrien](https://forum.ionicframework.com/u/Adrien)\
**Post date:** [April 22, 2014, 2:12am UTC](https://forum.ionicframework.com/t/http-get-not-working/3242/3 "2014-04-22T02:12:08Z")

</div>

The Ionic library is involved. Here is debugger output from a variant of the above code:

@file:///home/adrien/ionic\_projects/myapp/www/js/app.js:66 qFactory/defer/deferred.promise.then/wrappedErrback@file:///home/adrien/ionic\_projects/myapp/www/lib/ionic/js/ionic.bundle.js:18444 qFactory/defer/deferred.promise.then/wrappedErrback@file:///home/adrien/ionic\_projects/myapp/www/lib/ionic/js/ionic.bundle.js:18444 qFactory/defer/deferred.promise.then/wrappedErrback@file:///home/adrien/ionic\_projects/myapp/www/lib/ionic/js/ionic.bundle.js:18444 qFactory/createInternalRejectedPromise/\<.then/\<@file:///home/adrien/ionic\_projects/myapp/www/lib/ionic/js/ionic.bundle.js:18576 $RootScopeProvider/this.$get\</Scope.prototype.$eval@file:///home/adrien/ionic\_projects/myapp/www/lib/ionic/js/ionic.bundle.js:19447 $RootScopeProvider/this.$get\</Scope.prototype.$digest@file:///home/adrien/ionic\_projects/myapp/www/lib/ionic/js/ionic.bundle.js:19273 $RootScopeProvider/this.$get\</Scope.prototype.$apply@file:///home/adrien/ionic\_projects/myapp/www/lib/ionic/js/ionic.bundle.js:19553 done@file:///home/adrien/ionic\_projects/myapp/www/lib/ionic/js/ionic.bundle.js:15311 completeRequest@file:///home/adrien/ionic\_projects/myapp/www/lib/ionic/js/ionic.bundle.js:15512 createHttpBackend/\</xhr.onreadystatechange@file:///home/adrien/ionic\_projects/myapp/www/lib/ionic/js/ionic.bundle.js:15458

---

<div class="post-metadata">

**Author:** ![snowman4415](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@snowman4415](https://forum.ionicframework.com/u/snowman4415)\
**Post date:** [April 22, 2014, 2:15am UTC](https://forum.ionicframework.com/t/http-get-not-working/3242/4 "2014-04-22T02:15:31Z")

</div>

Don’t you mean `People.all` instead of `People.query`?

---

<div class="post-metadata">

**Author:** ![Adrien](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@Adrien](https://forum.ionicframework.com/u/Adrien)\
**Post date:** [April 22, 2014, 2:20am UTC](https://forum.ionicframework.com/t/http-get-not-working/3242/5 "2014-04-22T02:20:23Z")

</div>

Yes, People.all, I changed it to that and it still doesn’t work. The new code I’m trying is placed directly in my .controller and it also doesn’t work:

```
var responsePromise = $http.get('http://localhost:3000/people');
responsePromise.then(function (response) {
	$scope.people = response.data;
},function (response) {
	throw new Error('Something went wrong...');
});

```

The backend works, I’ve verified it with curl. And the backend logfile shows a status 200 OK response.

---

<div class="post-metadata">

**Author:** ![aaronksaunders](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/aaronksaunders/32/13729_2.png) [@aaronksaunders](https://forum.ionicframework.com/u/aaronksaunders)\
**Post date:** [April 22, 2014, 2:59am UTC](https://forum.ionicframework.com/t/http-get-not-working/3242/6 "2014-04-22T02:59:43Z")

</div>

if you dont use promises, does it work?

```
$http({method: 'GET', url: 'http://localhost:3000/people'})
  .success(function(data) {
    $scope.people = data;
  });

```

---

<div class="post-metadata">

**Author:** ![Adrien](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@Adrien](https://forum.ionicframework.com/u/Adrien)\
**Post date:** [April 22, 2014, 3:08am UTC](https://forum.ionicframework.com/t/http-get-not-working/3242/7 "2014-04-22T03:08:12Z")

</div>

No, still doesn’t work, and it also now makes 2 GET requests rather than just 1. Ah, my second approach also made 2 GET requests, but when I tried getting the data in a .factory it only made 1 request.

---

<div class="post-metadata">

**Author:** ![Calendee](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/calendee/32/13656_2.png) [@Calendee](https://forum.ionicframework.com/u/Calendee)\
**Post date:** [April 22, 2014, 1:20pm UTC](https://forum.ionicframework.com/t/http-get-not-working/3242/8 "2014-04-22T13:20:36Z")

</div>

You’re probably going to need to create a CodePen sample for us to be much more help. It’s hard to troubleshoot with just a few snippets of code.

---

<div class="post-metadata">

**Author:** ![Adrien](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@Adrien](https://forum.ionicframework.com/u/Adrien)\
**Post date:** [April 22, 2014, 7:23pm UTC](https://forum.ionicframework.com/t/http-get-not-working/3242/9 "2014-04-22T19:23:41Z")

</div>

The example is pretty strait forward, and conforms to what I’ve read both in an Angular book and on this forum. I have deadlines to meet, so I need to go back to coding my apps natively. Ionic is a nice looking framework and a good piece of concept software. I’ll check in on it every so often and am looking forward to using it in a production app. Thanks!
