title: Angular returns undefined
body: <p>I have API for getting information about one specific restaurant in the database, but I have to get it with a POST request. I successfully get <code>restaurantID</code> from auth.service and another API when the restaurant is logged in, But when I tried to log restaurant in console, I get <code>undefined</code>. Uniformly I don't have permission to show API here. The code:</p>
  
  <p>restaurant.service.ts</p>
  
  <pre class="lang-js prettyprint-override"><code>import { Injectable } from '@angular/core';
  import { HttpClient } from '@angular/common/http';
  import { Observable } from 'rxjs';
  import { map } from 'rxjs/operators';
  import { Restaurant } from '../models/Restaurant';
  import { LoggedRestaurant } from '../models/LoggedRestaurant';
  
  import { AuthService } from './auth.service'
  
  @Injectable({
    providedIn: 'root'
  })
  export class RestaurantService {
  
    private restaurantUrl = 'https://dm.dnevnimeni.com/dmnew/podacirestorana.php';
  
    public restaurant: Restaurant;
    public loggedRestaurant: LoggedRestaurant
    public restaurantID = this.authService.currRestaurant[0].id
  
    constructor(private http: HttpClient, private authService: AuthService) { }
  
    getRestaurant(ID): Observable&lt;LoggedRestaurant&gt; {
  
      console.log('ID je' + this.restaurantID);
  
      return this.http.post&lt;LoggedRestaurant&gt;(this.restaurantUrl, ID);
    }
  
  }
  </code></pre>
  
  <p>informacije.component.ts</p>
  
  <pre class="lang-js prettyprint-override"><code>import { Component, OnInit } from '@angular/core';
  import { AuthService } from '../services/auth.service';
  import { RestaurantService } from '../services/restaurant.service';
  import { Restaurant } from '../models/Restaurant';
  import { LoggedRestaurant } from '../models/LoggedRestaurant';
  import { Observable } from 'rxjs';
  
  @Component({
    selector: 'app-informacije',
    templateUrl: './informacije.component.html',
    styleUrls: ['./informacije.component.scss']
  })
  export class InformacijeComponent implements OnInit {
    restaurant: Restaurant;
    loggedRestaurant: LoggedRestaurant;
    restaurantID = this.authService.currRestaurant[0].id;;
  
    constructor(private restaurantService: RestaurantService, private authService: AuthService ) { }
  
    getRestaurant() {
       this.restaurantService.getRestaurant().subscribe(data  =&gt; {
        this.loggedRestaurant = data;
      });
  
    }
  
    ngOnInit() {
  
      this.getRestaurant();
  
      this.restaurant = this.authService.currRestaurant[0];
      console.log(this.restaurant)
      console.log(this.loggedRestaurant)
  
      this.restaurantID = this.restaurant.id;
      console.log(this.restaurantID)
      this.restaurantService.restaurantID =this.restaurantID;
  
    }
  }
  
  
  </code></pre>