Wednesday, May 24, 2017

.toPromise() off a this.http.post or this.http.put Observable implementation is legit.

You may then chain .then() onto .toPromise() to use the Promise API. There is also .catch() which seems to only manage the right half of .then() if you will, the second parameter.

 
 

Addendum 6/19/2017: One of the great things about this is that you may actually do what's best with it on the TypeScript side it lieu of having it bleed up to the template to take shape.

return this.http.get(myUrl)
   .toPromise()
   .then(this.manageSuccess, this.manageError)
   .catch(this.manageError);

No comments:

Post a Comment