[英]Set cookie on the header of a POST request using angular4 service
我想使用angular4通过HTTP POST请求标头传递一些cookie。 在这里,我正在调用一个外部API,并尝试传递此特定的cookie。 我已经用谷歌搜索,但是还没有找到正确的解决方案。 请同样帮我。 以下是我尝试过的代码。
public getTransactionStatus(transactionID: string): Promise<any> {
let header = new Headers;
let body = { "transactionID": "123" };
header.append('content-type', 'application/json');
header.append('set-cookie', 'test=hi; FedAuth=sadsa54ea4da5');
return this.http.post(uri, body, { headers: header })
.toPromise()
.then((res) => {
let temp = res.json();
return { 'statusCode': 200, 'message': 'success', 'result': temp, 'error': {} };
})
.catch((error) => {
return { 'statusCode': 200, 'message': 'failed', 'result': {}, 'error': error };
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.