I am considering moving all the business logic into the auth service and simply calling the method on the component side. Since none of my functions return anything, I wonder if it's okay or if they will hang.
COMPONENT
credentials: Credentials = {
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1d6d7c7e686f7c6f68797c737478715d7a707c74">[email protected]</a>',
password: '123'
}
onLogIn(): void {
this.authService.logIn(this.credentials.email, this.credentials.password);
}
SERVICE
public logIn(email: string, password: string): void {
this.http.post<any>('http://localhost:3100/login', { email, password })
.subscribe(user => {
localStorage.setItem('TOKEN', user.token)
this.router.navigateByUrl('/home');
});
}