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 });
}