import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { BehaviorSubject, Observable, tap } from "rxjs";
import { environment } from "../../../environments/environment";

@Injectable({providedIn: 'root'})
export class ApiService {
  apuUrl = environment.api;
  data$: BehaviorSubject<any> = new BehaviorSubject<any>(null);
  constructor(private httpClient: HttpClient) {}

  getData(id: string): Observable<any> {
    return this.httpClient.get(`${this.apuUrl}/tb-code-details/scan/${id}`).pipe(tap((res) => {
      this.data$.next(res);
    }));
  }

}
