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

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

  constructor(private http: HttpClient) { }

  getAllUsers(){
    return this.http.get<User[]>("http://localhost:8080/users");
  }

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