Returning promise problem


I got a provider “fetchdata” to return promise


    return new Promise(function(resolve, reject)

    let link = ''+id;

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


and i am calling the provider by

this.fetchdata.getPostDetail( => 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())


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.