
This is my userservice.ts file code
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 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);
})
);
}
}
Based on the server response you can acces your token and using interceptors you can append the token to any future requests if verification is needed.