2016-08-18 38 views
0

我想在超时发生之前返回缓存响应,然后更新缓存。是否有可能通过请求拦截器做出假响应?

我尝试这样做:

.factory('TestInterceptor', TestInterceptor); 

function TestInterceptor($q) { 
    return { 
     request: request, 
     response: response 
    }; 

    function request(config) { 
     ... 
     return $q.resolve(fakeResponse); 
     ... 
    } 
    function response() { 
    .... 
    } 
} 

,但它不工作。

回答

1

这是不可能的。 As the manual says

请求:拦截器被一个http配置对象调用。该功能可以自由修改配置对象或创建一个新的配置对象。该函数需要直接返回配置对象,或者包含配置或新配置对象的承诺。

相关问题