title: How can I process results from http.get() in Angular 6/RxJS 6?
body: <p>I'm trying to upgrade an application from Angular 5 to Angular 6 and having trouble figuring out how to use RxJS's new syntax. Here's the code I'm trying to migrate:</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { HttpClient } from '@angular/common/http';
  import { Observable } from 'rxjs/Observable';
  import 'rxjs/add/operator/map';
  
  @Injectable()
  export class SearchService {
    constructor(private http: HttpClient) {}
  
    getAll() {
      return this.http.get('assets/data/people.json');
    }
  
    search(q: string): Observable&lt;any&gt; {
      if (!q || q === '*') {
        q = '';
      } else {
        q = q.toLowerCase();
      }
      return this.getAll().map((data: any) =&gt; {
        const results: any = [];
        data.map(item =&gt; {
          // check for item in localStorage
          if (localStorage['person' + item.id]) {
            item = JSON.parse(localStorage['person' + item.id]);
          }
          if (JSON.stringify(item).toLowerCase().includes(q)) {
            results.push(item);
          }
        });
        return results;
      });
    }
  
    get(id: number) {
      return this.getAll().map((all: any) =&gt; {
        if (localStorage['person' + id]) {
          return JSON.parse(localStorage['person' + id]);
        }
        return all.find(e =&gt; e.id === id);
      });
    }
  
    save(person: Person) {
      localStorage['person' + person.id] = JSON.stringify(person);
    }
  }
  </code></pre>
  
  <p>I know the imports should change to:</p>
  
  <pre><code>import { Observable } from 'rxjs';
  import { map } from 'rxjs/operators';
  </code></pre>
  
  <p>And you're supposed to use <code>pipe()</code> instead of <code>map()</code> now, but I'm having issues figuring out how. It'd be awesome if it was as simple as the following, but it doesn't seem to be.</p>
  
  <pre><code>    return this.getAll().pipe(
        map(data: any) =&gt; {
          const results: any = [];
          data.map(item =&gt; {
            // check for item in localStorage
            if (localStorage['person' + item.id]) {
              item = JSON.parse(localStorage['person' + item.id]);
            }
            if (JSON.stringify(item).toLowerCase().includes(q)) {
              results.push(item);
            }
          });
          return results;
      }));
  </code></pre>