import {Injectable} from "@angular/core";
import {BehaviorSubject} from "rxjs";
import {HttpClient} from "@angular/common/http";

@Injectable({providedIn:'root'})
export class ErvuDataService {

  public message = new BehaviorSubject<any>(null);

  constructor(private httpClient: HttpClient) {
  }

  public getData(): any {
    this.httpClient.get("recruit",
              {
                headers: {
                  "Content-type": "application/json"
                },
                observe: "response"
              })
        .toPromise()
        .then(res => this.message.next(res.body))
        .catch((reason) => {
          throw new Error("Failed to get data: " + reason)
        });
  }
}
