title: Cannot read property 'asObservable' of undefined
body: <p>I am building a search function over a JSON API and I am getting this error: </p>
  
  <h3>Error: Uncaught (in promise): TypeError: Cannot read property 'asObservable' of undefined</h3>
  
  <p>I'm not familiar with angular and can't seem to find the problem.</p>
  
  <p>productService.ts</p>
  
  <pre><code>import { Observable, of, Subscription, Subject } from "rxjs";
  
  
  
  searchResults = new Subject&lt;Product[]&gt;();
  
  searchProduct(term: string): Subscription {
        console.log('Service is searching: ' + term );
        return this.http.get&lt;Product[]&gt;(this.searchURL + term).subscribe(
          results =&gt; this.searchResult.next(results));
  
      }
  
      getSearchResult(): Observable&lt;Product[]&gt; {
        return this.searchResult.asObservable();
      }
  </code></pre>
  
  <p>component.ts</p>
  
  <pre><code> searchResult: Product[];
  
   constructor(
           private productService:ProductService,
           private router: Router
      ) { 
        this.productService.getSearchResult().subscribe(results =&gt; {
            this.searchResult = results;
          })
  
      }
  </code></pre>