title: How to return the result of an observable
body: <p>I just want to return the result of the subscription (which is an array) to the <code>getData</code> function. </p>
  
  <p>i have a component which depends on the return value of the getData method to function</p>
  
  <pre><code>import { ReportsService } from './../../../../../../services/reports.service';
  import { Component, OnInit } from '@angular/core';
  
  @Component({
    selector: 'app-cardyesterday',
    templateUrl: './cardyesterday.component.html',
    styleUrls: ['./cardyesterday.component.css']
  })
  export class CardyesterdayComponent implements OnInit {
    salesCounter: any;
    amountCounter: any;
    changeCounter: any;
    changePeople: any;
    constructor(private report: ReportsService) { }
  
    ngOnInit() {
      const d = this.report.getData();
    }
  
  
  }
  </code></pre>
  
  <p>here is the service</p>
  
  <pre><code>import { AuthService } from './auth.service'; 
  import { Injectable } from '@angular/core';
  
  @Injectable({ 
      providedIn: 'root' 
  }) 
  export class ReportsService { 
      user: String; 
      constructor(private authService: AuthService) { } 
      getData() { 
          this.authService.getSales().subscribe(d =&gt; { 
              this.user = d.data; 
          }, 
          error =&gt; console.log(`error is ${error}`), 
          this.hh.bind(this)); 
          return this.user 
      } 
  
      hh() { 
          return this.user 
      } 
  }
  </code></pre>
  
  <p>so how do i get the getData method in ReportsService to return the value of the subscription( which is an array)</p>