2

Using $httpBackend, how can I use expectGET with a url that has query params? The order doesn't matter, and the value doesn't matter.

$httpBackend
  .expectGET('/api/my_endpoint/example?X=false&Y=someethingelse&Z=anotherthing')
  .respond(200, {});

Using $resource this is how I declare it:

  get: {
      method: 'GET',
      url: '/api/my_endpoint/example',
      params: {
        X: '@X',
        Y: '@Y',
        Z: '@Z',
      }
    }
cusejuice
  • 10,285
  • 26
  • 90
  • 145
  • 1
    http://stackoverflow.com/questions/32003963/httpbackend-with-request-with-query-param/32004266?noredirect=1#comment51911672_32004266 may help – Abhiram mishra Aug 14 '15 at 09:36

1 Answers1

1

You can also use a regular expression instead of a string for the url parameter. So

$httpBackend
    .expectGET(/\/api\/my_endpoint\/example.*/)
    .respond(200, {});

If it gets more complex a function can also be set.

rainerhahnekamp
  • 1,087
  • 12
  • 27