What is the difference between these two? Both seems to make a GET to /users and retrieve them.
Restangular.one('users').getList().then(function(users) {
// do something with users
});
Restangular.all('users').getList().then(function(users) {
// do something with users
});
I understand that you can do one('users', 123) and it will retrieve /users/123 but without the second argument it seems to be the same thing. Why not just have one method in that case?
The one()
function has a second argument that accepts an id e.g. .one('users', 1)
.
one('users', 1).get()
translates to /users/1
all('users').getList()
translates to /users
Unlike all()
, one()
is not generally used with .getList()
without argument. However, if you were to call .one('users', 1).getList('emails')
or .one('users', 1).all('emails').getList()
, then you would make a GET request to /users/1/emails
.