ionic 3如何通过帖子

时间:2018-03-06 11:19:00

标签: angular post ionic3

如何通过邮寄获取数据。我需要帮助。 我的代码:

 getmapdetail(){
    return new Promise(resolve => {
      this.http.post(this.apiUrl, JSON.stringify({id:3})).subscribe(data =>{

        resolve(data);
      },err =>{
        console.log(err);
      });
    })
  }

1 个答案:

答案 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
})