【发布时间】:2019-11-15 06:36:50
【问题描述】:
我正在尝试为其中一个获取请求设置标头。以下是函数:
getLeads(jwtToken: string): Observable<any>{
const headers = new HttpHeaders();
const authroizationToken = 'bearer '.concat(jwtToken);
console.log(authroizationToken); ------------------> prints the token
headers.append('Authorization', authroizationToken);
console.log(headers.get('Authorization')); ---------------------> this prints null
var result = this.http.get<Leads>(this.getLeadsUrl, {headers});
return result;
}
但由于某种原因,heades.get('Authorization') 为空,我无法弄清楚原因。任何帮助将不胜感激。
【问题讨论】:
-
这个问题已经在stackoverflow.com/a/47805759/2358409得到解答
标签: angular angular-httpclient