2017-05-12 64 views
0
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 { 

      }; 
     }) 
    ); 

控制檯中沒有錯誤。但我無法在chrome中的網絡選項卡下的請求標題選項卡中看到我的標題。

回答

0
headers = new Headers(); 


getData() { 
    headers.append('Content-Type', 'application/json'); 

    return this.http.get('URL',{headers: this.headers}) 
    .map((res: Response) => res.json()); 
} 
+0

這是我的服務文件 私人頭文件:any; (私人http:http){ this.headers = } \t private getReports ='reports/all?calFilterType = Day&date = 2017-05-05'; getLogData(參數:任何)//this.headers.append('Content-Type','application/json'); this.headers.append('X-Authorization','SOME TOKEN'); \t \t return this.http.get(this.Url + this.getReports + parameter,{headers:this.headers}).map((res:Response)=> res.json()); } –

+0

THIS IS MY FILE及部件從那裏我打電話本服務 公共getLogData(值:任何){ this.logManagerService.getLogData(值).subscribe( 數據=> { this.testResponse =數據; 控制檯.log(「我可以看到這裏的數據:」,this.testResponse); } ); –

相關問題