Angular2 services 如何在angular2中的$http.get方法中设置头
控制台中没有错误。但我无法在chrome的“网络”选项卡下的“请求标题”选项卡中看到我的标题 这是我的服务文件私有头:任意;构造函数(私有http:http){this.headers=newheaders();}private getReports='reports/all?calFilterType=Day&date=2017-05-05';getLogData(参数:any){//this.headers.append('Content-Type','application/json');this.headers.append('X-Authorization','SOME-TOKEN');返回this.http.get(this.Url+this.getReports+参数,{headers:this.headers}).map((res:res:Response=>res.json());)这是我调用此服务的COMPONET文件public getLogData(value:any){THIS.logManagerService.getLogData(value).subscribe(data=>{THIS.testResponse=data;console.log(“我在这里看不到数据:”,this.testResponse);});Angular2 services 如何在angular2中的$http.get方法中设置头,angular2-services,Angular2 Services,控制台中没有错误。但我无法在chrome的“网络”选项卡下的“请求标题”选项卡中看到我的标题 这是我的服务文件私有头:任意;构造函数(私有http:http){this.headers=newheaders();}private getReports='reports/all?calFilterType=Day&date=2017-05-05';getLogData(参数:any){//this.headers.append('Content-Type','application/json');
let headers1 = new Headers({'Content-Type': 'application/json'});
headers1.append('X-Authorization','some code');
let options = new RequestOptions({ headers: headers1,body: {} });
this.http.get('http://locahost:8080/dmat/logmgr/v1/reports/all?calFilterType=Day&date=2017-05-05'+paramerter, options ).subscribe(
(data => {
if(data.json().status === '200'){
console.log('data',data);
}else {
};
})
);
headers = new Headers();
getData() {
headers.append('Content-Type', 'application/json');
return this.http.get('URL',{headers: this.headers})
.map((res: Response) => res.json());
}