title: How to change a promise with async await function to observable?
body: <p>I have a Nestjs rest server with a controller and a service.</p>
  
  <p>In my controller, there is the get function, when someone makes a get request:</p>
  
  <pre><code>@Get()
  getAllFoos() {
      return this.fooService.getAllFoos();
  }
  </code></pre>
  
  <p>In my service, there is this function to get the documents from a database</p>
  
  <pre><code> async getAllFoos(): Promise&lt;foos[]&gt; {
      try {
          return await this.fooModel.find().exec();
      } catch(e) {
          return e;
      }
  </code></pre>
  
  <p>This works!
  I now need to change this to make it work with observables.
  I changed the controller to:</p>
  
  <pre><code>@Get()
  getAllFoos() {
      this.fooService.getAllFoos().subscribe(
          response =&gt; {
              console.log(response);
  
          },
          error =&gt; {
              console.log(error);
          },
          () =&gt; {
              console.log('completed');
  
      });
  }
  </code></pre>
  
  <p>And the service to this:</p>
  
  <pre><code>    getAllFoos(): Observable&lt;foos[]&gt; {
          try {
              this.fooModel.find().exec();
          } catch(e) {
              return e;
          }
      }
  </code></pre>
  
  <p>The error I get is</p>
  
  <pre><code>[Nest] 7120   - 2019-2-20 15:29:51   [ExceptionsHandler] Cannot read property 'subscribe' of undefined +4126ms
  </code></pre>
  
  <p>The error comes from </p>
  
  <pre><code>this.fooService.getAllFoos().subscribe(
  </code></pre>
  
  <p>this line from the controller. I really have no clue, what to change to make it work now.</p>
  
  <p>Any help or idea is appreciated!</p>