Is there an easy way to whitelist HTTP requests with ngMockE2E

后端 未结 1 1283
慢半拍i
慢半拍i 2020-12-21 06:35

Due to some infrastructure changes (namely servers & VPNs) there are times I want to run our application in an offline mode. I\'ve been able to implement this

相关标签:
1条回答
  • 2020-12-21 07:12

    That's the recipe I've used for whitelisting

    app.run(function ($httpBackend) {
        // mocked requests, should come first
        $httpBackend.when('GET', 'mock').respond(200, {});
    
        // whitelisted real requests, should come last
        angular.forEach(['GET', 'DELETE', 'JSONP', 'HEAD', 'PUT', 'POST', 'PATCH'], function (method) {
            $httpBackend.when(method).passThrough();
        });
    });
    

    And I'm quite sure that precedence matters here.

    0 讨论(0)
提交回复
热议问题