0
로컬 저장소에서 토큰을 가져 와서 헤더에 설정하려고하지만 토큰이 설정되지 않은 이유를 알 수 없습니다. 이 storage
약속 해결 얻을 얻을 기다리고 있기 때문에 귀하의 header
로컬 스토리지의 데이터에 액세스하고 이온 2의 서버로 보내는 올바른 방법은 무엇입니까?
getMurals() {
return this.http.get(AppSettings.API_ENDPOINT+'/murals', this.getHeader())
.map((response: Response) => response.json());
}
private getHeader() {
let header = new Headers();
this.storage.get('token').then((token)=>{
if(token){
header.append('authorization',token);
header.append('Content-Type','application/x-www-form-urlencoded');
}
})
return new RequestOptions({ headers: header });
}