title: Angular 7 Transform Observable response to a new observable object
body: <p>I have an api which responses like this and I am using rxjs observables</p>
  
  <pre><code>[{
    "error": "error_1",
    "types": [
       {
         "type": "new_type"
       },
       {
         "type": "old_type"
       }
    ],
    "date": "2019-08-29"
  }]
  </code></pre>
  
  <p>I need to transform it into a new json format so i can get the response format i wanted.</p>
  
  <p>I have tried pipe(map()) but i get error that Type '<code>Observable&lt;void&gt;</code>' is not assignable to type '<code>Observable&lt;Error[]&gt;</code>'</p>
  
  <p>My Model</p>
  
  <pre><code>export interface Data {
      error: string,
      types: Types[],
      date: string
  }
  
  interface Types {
      type: string
  }
  </code></pre>
  
  <p>My Service.ts</p>
  
  <pre><code>getError(): Observable&lt;Data[]&gt; {
      return this.http.get&lt;Data[]&gt;(url);
    }
  </code></pre>
  
  <p>This is what i tried so far and i deleted the code which produces error
  My Component.ts</p>
  
  <pre><code>getUserErrors(user): Observable&lt;Data[]&gt; {
      return this.getData.getError()
        .pipe(map((x) =&gt; x.filter(one =&gt; one.error !== null)))
  }
  </code></pre>
  
  <p>Here is the observable output i need</p>
  
  <pre><code>[{
    "new_error": "error_1",
    "type_1": "new_type",
    "date": "2019-08-29"
  }]
  </code></pre>
  
  <p>Thank you for those who will help</p>