title: Angular 5 data request
body: <p>I've build an application with Angular 5 and Java Spring Boot.</p>
  
  <p>I currently have the problem that I can't take the received data out of my data service in Angular.</p>
  
  <p>This is my data service:</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { HttpClient } from '@angular/common/http'
  
  import 'rxjs/add/operator/toPromise';
  
  import { Observable } from 'rxjs/Observable';
  
  @Injectable()
  export class DataService {
  
    constructor(private http: HttpClient) { }
  
    getClasses(): Observable&lt;any&gt; {
      return this.http.get('//localhost:8080/classes');
    }
  }
  </code></pre>
  
  <p>This is the component where I want to put the data:</p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  
  import { DataService } from '../data.service';
  
  @Component({
    selector: 'app-classes',
    templateUrl: './classes.component.html',
    styleUrls: ['./classes.component.css']
  })
  export class ClassesComponent implements OnInit {
  
    classes: Array&lt;any&gt;;
  
    constructor(private dataService: DataService) { }
  
    ngOnInit() {
      this.getClasses();
    }
  
    getClasses(): void {
      this.dataService.getClasses().subscribe(data =&gt; {this.classes = data});
    }
  }
  </code></pre>
  
  <p>This is what I get from console.log(data): </p>
  
  <pre><code>(3) [{…}, {…}, {…}]
  0: {version: null, id: 1, name: "3AHIT"}
  1: {version: null, id: 2, name: "4AHIT"}
  2: {version: null, id: 3, name: "5AHIT"}
  length: 3
  __proto__: Array(0)
  </code></pre>
  
  <p>And this from console.log(this.classes):</p>
  
  <pre><code>undefined
  </code></pre>
  
  <p>I used this tutorial for my application: <a href="https://developer.okta.com/blog/2017/12/04/basic-crud-angular-and-spring-boot" rel="nofollow noreferrer">https://developer.okta.com/blog/2017/12/04/basic-crud-angular-and-spring-boot</a></p>
  
  <p>I haven't found anything that helped me and I hope that somebody can help me here.</p>
  
  <p>Thanks in advance.</p>