ses ses - 1 year ago 79
AngularJS Question

AngularJS $httpBackend - "No more request expected" error

It seems this is working solution that shows how to work with


But for my case:


app.config(['$routeProvider', function($routeProvider) { $routeProvider.

when('/', {templateUrl: 'partials/user-list.html'}).


faked service:$httpBackend) {

var users = [{"id":1,"name":"bob","email":""}, {"id":2,"name":"bob2","email":""}]

$httpBackend.whenGET('/rest/users').respond(function(method,url,data) {
console.log("Getting users");
return [200, users, {}];


real service:

services.factory('Users', function($resource){
return $resource('/rest/users', {}, {
get: {method: 'GET', isArray:true}

I have error when go to my "/" route that redirects me to

Error: Unexpected request: GET partials/user-list.html No more request
at $httpBackend .../mysite/public/angular/libs/angular-1.2.0/angular-mocks.js:1060:9)

Question1: Does
prevent doing any other

I tried to use passThrough method to let http hit real server side:


But this does not help.

ses ses
Answer Source

Ah.. Sorry I just was wrong with my RegEx:

if type this $httpBackend.whenGET(/partials/).passThrough();

Then all start working.

So, I got my lesson: don't forget to put: passThrough(); with right RegEx.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download