I am writing a frontend without backend ajax for now. I am using angular-mocks
to simulate API call like this:
$httpBackend.when('GET', '/somelink').respond(function(method, url, data) {
//do something
});
However, if the ajax passes params: {id:12345}
, it will append to the url to be '/somelink?id=12345'
. That doesn't catch by the when('GET', '/somelink')
Is there a way to use RegEx or some trick to work around this? Just so that regardless of what is inside params
, the respond()
still gets called?
Thanks.
UPDATE 1:
I cannot use .whenGET
because my backendless system has POST
and PUT
as well. So I need to keep it generic. This two params .when('GET', '/somelink')
are actually variables in my code.
Since '/somelink'
is a variable in another JSON
, having RegEx /\/somelink/
in JSON doesn't seem to work. At least that's what I see for now.