rxjs-docs icon indicating copy to clipboard operation
rxjs-docs copied to clipboard

docs-RxJs for Angular Developers: Using HttpModule

Open mustafamg opened this issue 8 years ago • 2 comments

Many angular developers convert observer returned for HTTP request to promise before using them. This guidance will introduce to the developer how to declaratively use the returned observers instead of transforming it to promote.

mustafamg avatar Nov 18 '17 19:11 mustafamg

The Angular Docs have a great example of this... https://angular.io/guide/http#making-a-request-for-json-data

    this.http.get('/api/items').subscribe(data => {
      // Read the result field from the JSON response.
      this.results = data['results'];
    });

Only1MrAnderson avatar Nov 29 '17 07:11 Only1MrAnderson

Yes, this one way of doing that. The other way is returning the observer to the template instead of the results coming from the subscription. The other way, is as follow: this.results = this.http.get('/api/items').map(data => data['results']); @Only1MrAnderson If you are going to work on that, please use both patterns in your documentation.

mustafamg avatar Nov 29 '17 09:11 mustafamg