Error: [$resource:badcfg] Error in resource configuration. Expected response to contain an array but got an object

angularjs

Solution

Add `{}` after `'/posts'`.

bulletinApp.factory('Post', ['$resource', function($resource) { 
    return $resource('/posts', {}, {'query': {method: 'GET', isArray: false}}); 
}]);

For details, see this post.

Problem

I am a complete noob with respect to angular, just going through a codeschool tutorial and I've hit my first hurdle. I am getting `Error: [$resource:badcfg] Error in resource configuration. Expected response to contain an array but got an object` Here is my code: ``` var bulletinApp = angular.module('bulletinApp', ['ngResource']); bulletinApp.controller('PostsController', ['$scope', 'Post', function($scope, Post) { $scope.heading = 'Welcome'; $scope.posts = Post.query(); $scope.newPost = { title: 'Test Post' } }]); bulletinApp.factory('Post', ['$resource', function($resource) { return $resource('/posts'); }]); ``` I found an answer here: Error in resource configuration while using $resource.query() function with AngularJS/Rails That says I should add this to my resource declaration: ``` 'query': {method: 'GET', isArray: false } ``` Problem being I have no idea where I am supposed to add this, or even if this is the problem I'm having? EDIT: ``` bulletinApp.factory('Post', ['$resource', function($resource) { return $resource('/posts', {'query': {method: 'GET', isArray: false}}); }]); ``` After this I am still receiving the error. Also in the tutorial, there was no need for this and I've followed it pretty much to a tee, why would the get method be getting an object instead of an array?

Original source