【发布时间】:2018-02-13 18:20:22
【问题描述】:
我是 Angular 的新手。我无法读取 REST 服务响应标头中的令牌 (jwt)。如何阅读标题?这是我的代码:
loginUser(loginUser:Login,callback: (data) => void){
let body = JSON.stringify(loginUser)
const headerJson = {
'Content-Type': 'application/json'
}
let options = { headers: new HttpHeaders( headerJson ) };
return this.http.post(this.config.datiBean.urlLoginToken, body,options).subscribe(
res =>{
console.log("body :"+JSON.stringify(res)); //ok
callback(res);
}
/// at this point how can I read headers?
)};
}
感谢您的帮助
【问题讨论】:
-
看看angular.io/guide/http,它提到了您将如何阅读回复。
-
{ 观察:'响应'}
-
如果我插入返回 this.http.post (this.config.datiBean.urlLoginToken, body, {observe: "response"})。订阅(.....我从服务器 415(不支持的媒体类型)收到以下错误,因为服务器只接收 json 调用
标签: angular