import { Component, OnInit } from '@angular/core';
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { environment } from '../environments/environment';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
  title = 'app';
  loading = true;
  appVersion = environment.appVersion;
  apiVersion;
  connectedToApi = false;

  constructor(
    private http: HttpClient
  ) {}

  ngOnInit(): void {
    this.http.get(`/api/version`).subscribe(pApiVersion => {
      this.apiVersion = pApiVersion;
      this.connectedToApi = true;
      this.loading = false;
    }, error => {
      this.loading = false;
    });
  }
}
