0
我試圖從本地存儲獲取我的令牌並將其設置在標題中,但我不知道它爲什麼不設置。訪問本地存儲數據併發送到離子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 });
}