title: Angular subscribe() returning undefined
body: <p>How to I solve problem with subcribe() to my app.component if my console shows me the following thing: <strong>ERROR TypeError: Cannot read property 'subscribe' of undefined
  at AppComponent.push../src/app/app.component.ts.AppComponent.ngOnInit</strong> </p>
  
  <p><strong>data.service:</strong></p>
  
  <pre><code>   import { Injectable } from '@angular/core';
     import { Http, Response } from '@angular/http';
  
     import { Injectable } from '@angular/core';
     import { Observable, Subject, ReplaySubject } from 'rxjs';
     import { from, of, range } from 'rxjs/create';
     import { map, filter, switchMap } from 'rxjs/operators';
  
  
   @Injectable({
      providedIn: 'root'
      })
  
  
  export class DataService {
  
    constructor(private http: Http) { }
  
    fetchData(){
      this.http.get('assets/ninjas.json').pipe(
       map((res) =&gt; return res.json()))}}
  </code></pre>
  
  <p><strong>app.components:</strong></p>
  
  <pre><code>import { Component } from '@angular/core';
  import { DataService } from './data.service';
  
  @Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
  })
  
  export class AppComponent {
    title = 'app';
    ninjas = [];
  
    constructor(private newService: DataService){ }
  
    ngOnInit(){
     this.newService.fetchData().subscribe(
      (data) =&gt; this.ninjas = data;
     );
    }
   }
  </code></pre>