【问题标题】:How to add cookie to any http.get request in typescript and angular2?如何将 cookie 添加到 typescript 和 angular2 中的任何 http.get 请求?
【发布时间】:2017-07-10 07:10:14
【问题描述】:

似乎http.get 是被禁止的,因为我没有在请求中发送 cookie 值。如果我只是浏览链接,我会得到响应,因为浏览器会发送 cookie。我如何在 angular 2 的打字稿代码中做同样的事情?

【问题讨论】:

    标签: http angular cookies angular2-services


    【解决方案1】:

    查看此链接:

    https://angular.io/docs/ts/latest/api/http/index/RequestOptions-class.html

    您可以在获取请求时指定 RequestOptions(例如标头值)。我想您可以使用它以您需要的方式发送 cookie。您的问题中没有太多其他信息,所以我认为这是我能得到的最接近的信息。

    http 规范:

    https://angular.io/docs/ts/latest/api/http/index/Http-class.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-22
      • 2021-02-09
      • 1970-01-01
      • 2017-07-10
      • 1970-01-01
      • 1970-01-01
      • 2021-01-07
      • 1970-01-01
      相关资源
      最近更新 更多