如何通过邮寄获取数据。我需要帮助。 我的代码:
getmapdetail(){
return new Promise(resolve => {
this.http.post(this.apiUrl, JSON.stringify({id:3})).subscribe(data =>{
resolve(data);
},err =>{
console.log(err);
});
})
}
答案 0 :(得分:0)
// considering this is in some service
getmapdetail(){
return this.http.post(this.apiUrl, JSON.stringify({id:3})).map(data => data.json());
}
// inject that service in component
// call that service from component like this
this.service.getmapdetail().subscribe(data => {
// do what ever you want with data
})