-1

From the AngularJS 1.6.x $resource documentation I know that I can pass in query name/value parameters using a JavaScript object. For example {foo: "bar"} for the path path/example will access a RESTful URL using something like path/example?foo=bar.

But what if I want to pass a query parameter with no value, e.g. path/example?foo? Do I use {foo: ""} or {foo: null} or some other form? Thanks in advance.

Garret Wilson
  • 18,219
  • 30
  • 144
  • 272
  • 1
    What can be easier than just trying foo:"", foo: null, and see what happens? – Petr Averyanov Jun 14 '18 at 16:35
  • Related: [Is a url query parameter valid if it has no value?](https://stackoverflow.com/questions/4557387/is-a-url-query-parameter-valid-if-it-has-no-value). – georgeawg Jun 14 '18 at 19:30

1 Answers1

0

you should just be able to omit the query parameter. This is an example of a query that could return all users:

let User = $resource('/user/:userId', {userId: '@id'});
User.query().$promise.then(function(users) {
  allUsers = users;
});

https://docs.angularjs.org/api/ngResource/service/$resource#basic-usage

Phil Ninan
  • 1,108
  • 1
  • 14
  • 23