我有一堆不同的拦截器,只想在特定的$ resource端点上使用。我阅读了$ resource的interceptor属性,并进行了工作,但是在某些情况下,我希望为一个端点响应设置两个拦截器,就像正常的全局拦截器一样。这可能吗?
在用户$ resource的操作中,我想要添加一些类似于登录端点的内容:
var actions = {
login: {
method: 'POST',
url: '/api/auth/login',
interceptor: [AuthLoginInterceptor,AuthUserInterceptor]
},
logout: {
method: 'GET',
url: '/api/auth/logout',
interceptor: AuthLogoutInterceptor
},
update: {
method: 'PUT',
interceptor: AuthUserInterceptor
},...
我知道我可以只包含彼此的代码,因此在最坏的情况下,我只是重构解决方案,但如果可能的话,我宁愿保持原样。
那这样的事情呢?:
{
method: 'POST',
url: '/api/auth/login',
interceptor: {
response: function (config) {
return AuthLoginInterceptor.response(AuthUserInterceptor.response(config));
}
}
}
它似乎正在我正在使用的最小测试项目中工作。
根据我上面的评论回答。希望它对以后的这个问题的访问者有用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句