2

I'm trying to mock a $http get request with parameters. Using the actual $http service we could do something like this

 $http.get(url, {params : { articleId:10, id : 1}})
        .success(function (response) {
            defer.resolve(response.data);
        });

Can we do the same with $httpBacked?

 $httpBackend.when('GET', url, { params: { articleId: 10, id : 1}})
        .respond({data: areas});

The obvious unpleasant alternative is writing out the full expected url which I am hoping I don't have to do as this feels neater.

Thanks

Obi
  • 3,091
  • 4
  • 34
  • 56

2 Answers2

3

I had forgotten about this question, unfortunately the answer is that you have to specify the full get url with parameters

....just incase someone stumbles across this with the same problem

Obi
  • 3,091
  • 4
  • 34
  • 56
  • And you should mark your own answer as accepted then. Or are you waiting for someone to post a better "solution"? – j0k Sep 08 '15 at 07:57
  • I have to admit I think I was waiting for someone to either dispute or agree and then I just forgot about it, one can never assume to know it all with these things but I'll mark it as the answer. Thanks – Obi Sep 08 '15 at 11:56
1

Apparently the only thing that can be passed parameters in a regular expression. According to the documentation of angular only four parameters can be passed, method, url, data, and headers.