Ale*_*Grs 6 javascript angularjs angular-http
我想在导航器中使用带有cookie的资源.
使用$ http非常简单,因为我只需将withCredential设置为true:
$http({
method: 'POST',
url: url,
data: user,
withCredentials: true
});
Run Code Online (Sandbox Code Playgroud)
但是对于$ resource,我没有找到解决方案来点同样的...我在github上看到了关于这一点的讨论,但我认为对于所有请求,对于true的设置为true是不正常的.你知道怎么做吗?
Muh*_*eda 16
要更改$http
(因此为$ resource)的默认设置,您需要更改$httpProvider
.
withCredentials
全局设置如下:
angular.module('YOUR_APP')
.config(function($httpProvider) {
$httpProvider.defaults.withCredentials = true;
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6603 次 |
最近记录: |