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 httpClient = inject(HttpClient)

  login(u: string, p: string){
    const data={
      username: u,
      password: p
    }
    return this.httpClient.post<User>("http://localhost:4000/users/login", data)
  }

  register(u: User){
    return this.httpClient.post<string>("http://localhost:4000/users/register", u)
  }
}
