21
我正在尝试使用withCredentials向我的服务发送一个cookie,但无法找到如何实现它。 文档说:“如果服务器需要用户凭据,我们将在请求标题中启用它们”没有任何示例。 我尝试了几种不同的方法,但它仍然不会发送我的cookie。 这是我的代码到目前为止。angular 2 http withCredentials
private systemConnect(token) {
let headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('X-CSRF-Token', token.token);
let options = new RequestOptions({ headers: headers });
this.http.post(this.connectUrl, { withCredentials: true }, options).map(res => res.json())
.subscribe(uid => {
console.log(uid);
});
}
非常感谢!我希望他们会将此添加到文档中! :) – Lindstrom
它已经在头文件和RequestOptions源文件的注释中) 直到官方API文档还没有准备好 - 我们必须在源代码中使用注释) –
谢谢你将在未来中考虑到这一点:) – Lindstrom