Search code examples
angularjsjasminehttpbackend

Pass params to $httpBackend


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


Solution

  • 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