Angular 8:无法设置标题 [英] Angular 8: unable to set headers
本文介绍了Angular 8:无法设置标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从组件调用服务:
getToken() {
const httpOptions = {headers: new HttpHeaders({ 'Authorization': 'Basic c3ByaW5nLXNlY3VyaXR5LW9hdXRoMi1yZWFkLXdyaXRlLWNsaWVudDpzcHJpbmctc2VjdXJpdHktb2F1dGgyLXJlYWQtd3JpdGUtY2xpZW50LXBhc3N3b3JkMTIzNA==' })};
return this.http.post(this.rootUrl + "oauth/token?client_id=spring-security-oauth2-read-write-client&password=root1234&username=tarak@bambootv.com&grant_type=password", httpOptions);
}
该呼叫未显示 Authorization
,请检查以下图片:
The call not showing the Authorization
, check the image below:
推荐答案
您正在将标头作为请求正文发送.
You're sending the header as the request body.
您需要将其作为第三个参数传递给通话:
You need to pass it as a third param to the call:
this.http.post(url, null, httpOptions)
这篇关于Angular 8:无法设置标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文