2017-05-12 2 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 { 

      }; 
     }) 
    ); 

콘솔에 오류가 없습니다. 하지만 크롬에서 네트워크 탭 아래의 요청 된 헤더 탭에서 내 헤더를 볼 수 없습니다.

답변

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

이것은 내 서비스 파일 개인 헤더입니다. \t 생성자 (개인 http : Http) { this.headers = new Headers(); } \t 개인 getReports = 'reports/all? calFilterType = 요일 & 날짜 = 2017-05-05'; getLogData (매개 변수 : any) { //this.headers.append('Content-Type ','application/json '); this.headers.append ('X-Authorization', 'SOME TOKEN'); \t \t this.http.get (this.Url + this.getReports + 매개 변수, {headers : this.headers}) .map ((res : Response) => res.json())을 반환합니다. 콘솔 { this.logManagerService.getLogData (값) .subscribe ( 데이터 => { this.testResponse = 데이터 : } –

+0

이 I이 서비스를 공개 getLogData (값)를 부르고 WHERE FROM MY COMPONET 파일이며 .log ("나는 여기 데이터를 볼 수 없습니다 :", this.testResponse); } ); –

관련 문제