由网友(心若不动、风又奈何)分享简介:$httpBackend.whenGET('/restpath/api/v1/books').respond({// some data}); 我收到以下错误Error: Unexpected request: GET /restpath/api/v1/booksExpected GET /restpath/api...
$httpBackend.whenGET('/restpath/api/v1/books')
.respond({// some data});
我收到以下错误
Error: Unexpected request: GET /restpath/api/v1/books
Expected GET /restpath/api/v1/books?limit=10&start=1
对于expectGET我有以下内容,这将创建动态查询字符串。大多是开始的参数,和whenGET的一部分,我想服务器取决于开始
For the expectGET I have the following , and this creates dynamic query string. mostly the 'start' parameter, and the whenGET part, I am trying to server a dynamic content depending on the 'start'
$ httpBackend.expectGET('/ restpath / API / V1 /书籍限值为10安培;启动= 1'); //实际的服务放在这里,它执行$ http服务。我们不关心 $ httpBackend.flush();
推荐答案
如果你不关心你以后的参数?你可以这样做:
Hi if you dont care about the parameters after your '?' you can do this :
$httpBackend.expectGET(/.*?restpath/api/v1/books?.*/g).respond(200, '{}');
如果你所关心的第一个参数做到这一点:
if you care about the first param do this :
$httpBackend.expectGET(/.*?restpath/api/v1/books?limit=10.*/g).respond(200, '{}');
如果你关心他们都做到这一点:
if you care about them all do this :
$httpBackend.expectGET("/restpath/api/v1/books?limit=10&start=1").respond(200, '{}');
相关推荐
最新文章