Kevin
Kevin

Reputation: 365

Restangular get one

I think I am having trouble understanding Restangular. I am able to get all, but I can't get one.

I have tried both:

getById: function(id){
  return Restangular.one('user').get({user_id: id});
}

and:

getById: function(id){
  return Restangular.one('user', id).get();
},

Both result in the browser crashing from too much recursion.

The base url is already set.

Upvotes: 0

Views: 1952

Answers (1)

Kevin
Kevin

Reputation: 365

It was indeed my misunderstanding. I still don't fully understand Restangular, but I do now know I needed to use:

Restangular.all('user')

And, more specifically, in my case:

getById: function(id){
  return Restangular.all('user').get('?user_id=' + id);
},

Upvotes: 3

Related Questions