angularjs - Angular 2 GET withCredentials(接受来自服务器的cookie)

标签 angularjs typescript angular

我可以看到 withCredentials: true is implemented in angular 2 now

接受来自服务器的cookie。

但是我不确定应该如何使用它。

我试过了

this.http.get( API_PATH + 'auth/getSession/' + TOKEN, {
  withCredentials: true
} )

但是西兰花抛出错误

类型参数 '{ withCredentials: boolean; }' 不可分配给“RequestOptionsArgs”类型的参数

我使用 Angular CLI 的 1.0.0-beta.6。

最佳答案

withCredentials 可在 Angular2 的 RC2 版本中使用。 Angular CLI 1.0.0-beta.6 使用 RC1 版本。

您应该升级到 beta.8 才能使用 RC2+ 版本。

关于angularjs - Angular 2 GET withCredentials(接受来自服务器的cookie),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38080742/

相关文章:

html - 设计一个大的 JSON 字符串以多行显示而不是 1 大行

javascript - 使用 $filter 时,cloneConnectFn 不是函数

带子扩展面板的 Angular Material 扩展面板

javascript - Angular :如何从点击事件获取<li>而不是<ul>

Angular 通用 : Get Store in Guard on Server-side using NgRx

javascript - Angular指令充当其他元素的外观的好方法是什么?

angularjs - 在模板中使用光滑的轮播

typescript - 如何在 NestJS Controller 中使用 DTO 的验证组?

angular - "Can' t read the url"error for angular2 dynamic components with templateUrl

javascript - 脚本中的 Angular <div> 颜色变化