getNews(newsType : any){
this.storage.get("USER_INFO").then(right=>{
this.storage.get("sessionkey").then(temp=>{
this.email = JSON.parse(right).email;
this.newkey = temp;
this.authentification =JSON.stringify("Basic " + btoa(this.email+":"+ this.newkey+":"+key));
const body = newsType;
let headers = new Headers({
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': this.authentification
});
let options = new RequestOptions({headers : headers});
return this.http.post('http://api/getNews',body,options)
.map((data:Response) => data.json());
}, err =>{console.log("error on sessionkey",err)})
}, err =>{console.log("error on user",err)})
}
this.httpService.getNews(JSON.stringify(this.category)).subscribe(data => {
this.news = data.News;
});
}, err => {
console.log("Error:", err)
});
我想在嵌套函数成功后调用Api。 但是,当我在函数成功回调中执行它时,它给我错误,属性'订阅'不存在类型'void'上。属性“订阅”不存在类型'无效'角2中
我怎样才能返回API的价值,从服务到另一个.ts文
正如@Maximus说你要在父母返回的数据(外)级嵌套函数内部'返回this.storage。得到(“USER_INFO”)' – nivas
嘿,考虑接受[我的回答](https://stackoverflow.com/a/45160956/2545680)如果它帮助 –