Is It Possible To Set A Wildcard For $httpbackend Responses?
Suppose I have the following test code in AngularJS: var someURL; var dummyJSON; $httpBackend.whenGET(someURL).respond(dummyJSON); Is there a way of making this the response for a
Solution 1:
I've had luck with expressions like whenGET(/^\/api\//) – which means starts with /api/. In the regex, ^ will match the start of the string and \/ will match a literal / in the URL.
If that doesn't match your requests, try whenGET(/\/api\//) which should match absolute URLs as well as relative URLs.
Post a Comment for "Is It Possible To Set A Wildcard For $httpbackend Responses?"