title: Variable is undefined no matter what I do
body: <p>I am trying to call my API with Angular 8 and log the JSON response into the console, but no matter what I do, the console says something is undefined and not logging anything else.</p>
  
  <p>Component:</p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  import { Observable } from 'rxjs';
  import { HttpdaService } from '../httpda.service';
  import { Kbs } from '../kbs';
  
  @Component({
    selector: 'app-home',
    templateUrl: './home.component.html',
    styleUrls: ['./home.component.css']
  })
  export class HomeComponent implements OnInit {
    observableKbs: Observable&lt;any[]&gt;;
    kbs: Kbs[];
  
    constructor(private http: HttpdaService) { }
  
    ngOnInit() {
      this.getKbs();
      console.log(this.kbs);
    }
  
    getKbs() {
      this.observableKbs = this.http.getKbs();
      this.observableKbs.subscribe(
        kbs =&gt; this.kbs = kbs,
        err =&gt; this.http.checkErr(err)
      );
      return this.kbs;
    }
  }
  </code></pre>
  
  <p>Service:</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { HttpClient, HttpErrorResponse } from '@angular/common/http';
  import { Observable } from 'rxjs';
  import { Router } from '@angular/router';
  
  @Injectable({
    providedIn: 'root'
  })
  export class HttpdaService {
    serverUrl = 'http://127.0.0.1/';
  
    constructor(private http: HttpClient, private _router: Router) { }
  
    getKbs(): Observable&lt;any&gt; {
      return this.http.get&lt;any&gt;(this.serverUrl);
    }
  
    checkErr(err) {
      if (err instanceof HttpErrorResponse) {
          console.log(err.status);
      }
  }
  
    private extractData(res: Response) {
      let body = res.json();
      return body;
    }
  }
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>export class Kbs {
      'message': string;
  }
  </code></pre>
  
  <p>What receive when I call my API with cURL -</p>
  
  <pre><code>curl 127.0.0.1 
  
  {   "message": "welcome" }
  </code></pre>
  
  <p>This is what I get in the console -</p>
  
  <p><a href="https://i.stack.imgur.com/nLcJ0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nLcJ0.png" alt="enter image description here"></a></p>