我需要向我的一些 $http 调用添加一个查询字符串。 现在 $httpProvider.defaults.transformRequest 似乎接收到 2 个对象: data 和 headersGetter,都不允许我直接更改 url 或添加 get 变量。
有什么想法吗?
最佳答案
你需要一个拦截器。来自 $http 上的 Angular 文档:
There are two kinds of interceptors (and two kinds of rejection interceptors):
request: interceptors get called with http config object. The function is free to modify the config or create a new one. The function needs to return the config directly or as a promise.
关于angularjs - $httpProvider请求拦截器-获取参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17972982/