【发布时间】:2018-02-26 21:17:57
【问题描述】:
所以我的离子存储中有一个授权令牌,我必须通过 http 请求传递它,但我似乎无法从 storage.get.then 承诺中获取值。
getProducts(){
let headers = new Headers();
this.token= this.storage.get('Authorization').then((value)=>{
this.token= value;
return this.token;
});
headers.append("Authorization",this.token);
return this.http.get('https://vjtest.cobold.xyz/vapi/public/api/products',{headers: headers})
.map(res=> res.json());
}
【问题讨论】:
-
@wolverine 如果我将 http.get 放在里面,我会在订阅部分出错,因为 http.get return 不会从 getProduct 返回产品值//对不起,用文字表达不好跨度>