At first I had this, but got error Expected response to contain an object but got an array
:
angular.module('homeModule').factory("TodosFactory", ['$resource', function ($resource) {
return $resource('/api/todos/:todoId', {
todoId: '@_id'
});
}]);
So I changed to this:
angular.module('homeModule').factory("TodosFactory", ['$resource', function ($resource) {
return $resource('/api/todos/:todoId', {
todoId: '@_id'
}, {'save': {method: 'POST', isArray:true}}); // this line is added
}]);
I am saving an item to database, and returning list of objects as a result. An JSON array is returned, but I get this error.
Any suggestions?