Returning promise problem

I got a provider “fetchdata” to return promise

   getPostDetail(id)
  {

    return new Promise(function(resolve, reject)
    {

    let link = 'https://themooncreation.com/apps/data2.php?action=get_posts&id='+id;
    console.log(link);

      this.http.get(link).map(res => res.json()).subscribe(data =>
      {
  //        console.log("right here "+postDetail['USERNAME']);
          resolve(data);
          reject(console.log('some fail stuff'));
      });
    });

  }

and i am calling the provider by

this.fetchdata.getPostDetail(this.id).then(post => this.loadMap(post['LAT'], post['LON']));

but seems loadMap is not being called, anyone know why?

Can you try doing this instead:

getPostDetail(id: string): Promise<Whatever> {
  return this.http.get(link)
    .map(rsp => rsp.json())
    .toPromise();
}

it’s working now, thanks. but do you know why my version doesn’t work?

Perhaps because of lost execution context, but explicit Promise construction should be avoided.