0

I'm using ng-resource to access an API in the following way:

$resource('http://' + config.server.api + config.server.host + base_url + '/:id', {
    'id': '@id'
    },{
    'get' : {
        method : 'GET'
    },
    'add' : {
        method : 'PUT'
    },
    'update' : {
        method : 'POST'
    },
    'all' : {
        method  : 'GET',
        isArray : true
    },
    'del' : {
        method : 'DELETE'
    }
},{
    stripTrailingSlashes : false
});

And I am accessing the resource like so:

apiService.Businesses.query(function(data){
  $scope.businesses = data;
});

However, the request URL is: http://API_URL.com/businesses/:id

Or when I try to use 'resource.get':

apiService.Businesses.get({id:1}, function(data){
  $scope.businesses = data;
});

The request URL is http://API_URL.com/businesses/:id/[object%20Object]


I'm obviously missing something in the resource definition but I could not figure out what it was

BarakChamo
  • 3,321
  • 5
  • 30
  • 38
  • Seems to **[work fine](http://jsfiddle.net/ExpertSystem/LHwuH/)**. There is something else wrong with your code. Something you are not showing us... – gkalpak Jun 21 '14 at 16:25

1 Answers1

1

I still don't know what was the issue but switching the dependency seems to have solved it.

I'm using Bower and previously installed 'ng-resource'.

I tried to uninstall it and use 'angular-resource' instead and that did the trick.

BarakChamo
  • 3,321
  • 5
  • 30
  • 38