import { HttpClient } from '@angular/common/http';
import { inject, Injectable } from '@angular/core';
import { User } from '../models/user';

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

  constructor() { }

  private http = inject(HttpClient)

  private backPath = "http://localhost:8080/users"

  getUser(){
    return this.http.get<User>(`${this.backPath}/pera`)
  }

  getAllUsers(){
    return this.http.get<User[]>(`${this.backPath}`)
  }

  login(u: string, p: string){
    const data = {
      username: u,
      password: p
    }
    return this.http.post<User>(`${this.backPath}/login`, data)
  }
}
