title: Extract data from Angular 7 service using RxJS to subscribe to DotNetCore WebAPI
body: <p>I'm new to RxJs.</p>
  
  <p>We have a DotNetCore api, which returns a response model, with a Generic for the data:</p>
  
  <pre><code>public class SingleModelResponse&lt;T&gt; : ISingleModelResponse&lt;T&gt;
  {
      public Boolean DidError { get; set; }
      public String ErrorMessage { get; set; }
  
      public T Data { get; set; }
  }
  </code></pre>
  
  <p>The controller returns it like this:</p>
  
  <pre><code>    [HttpGet]
      [Route("{organisationId}/stats")]
      public async Task&lt;IActionResult&gt; GetStats(int organisationId)
      {
          var response = new SingleModelResponse&lt;OrganisationStatsDTO&gt;();
          try
          {
              var result =  await _service.GetStatsAsync(organisationId);
              response.Data = result;
          }
          catch (Exception ex)
          {
              response.DidError = true;
              response.ErrorMessage = ex.Message;
          }
          return response.ToHttpResponse();
      }
  </code></pre>
  
  <p>My angular service is set up to receive the OrganistionStats  :</p>
  
  <pre><code>   loadStats(organisationId: number): Observable&lt;OrganisationStats&gt; {
       const url = '/api/Organisation/' + organisationId + '/stats';
       return this.http.get&lt;OrganisationStats&gt;(url).pipe(
         map(response =&gt; response),
         tap(data =&gt; console.log('Stats: ' + JSON.stringify(data))),
         catchError(this.handleError)
       );
     }
  </code></pre>
  
  <p>The trouble is that it's not the OrganisationStats that is being returned but the SingleModelResponse. I'm having trouble working out how to change the service to extract the OrganisationStats from the data property.</p>
  
  <pre><code>  loadStats(organisationId: number): Observable&lt;OrganisationStats&gt; {
      const url = '/api/Organisation/' + organisationId + '/stats';
  
      return this.http.get&lt;SingleModelResponse&gt;(url).pipe(
        map(response =&gt; response),
        tap(data =&gt; console.log('Stats: ' + JSON.stringify(data))),
        catchError(this.handleError)
      );
    }
  </code></pre>