Here is the code from my userservice.ts file
export class UserService {
BASE_URL = "http://localhost:8082";
constructor(private httpClient:HttpClient) {}
public login(loginData:any){
return this.httpClient.post(this.BASE_URL+"/authenticate",loginData);
}
}
This is the content of my login.component.ts file
export class LoginComponent implements OnInit {
constructor(private userService:UserService){}
ngOnInit(): void {}
login(loginFormData:NgForm){
this.userService.login(loginFormData.value).subscribe(
(response) =>{
console.log(response);
},
(error=>{
console.log(error);
})
);
}
}