After following different tutorials, I have created a service that can transmit login details to the backend for validation and processing. Although I am able to generate appropriate error codes based on user input, I find myself wondering what to do next.
export class AuthService {
constructor(private http: HttpClient) { }
getUserDetails(email, password){
// post to API server - return user info if valid
return this.http.post('http://localhost/api/listee/task_login.php', {
email,
password
}).subscribe(data => {
console.log(data, 'returned from login attempt')
var theData: any;
theData = data;
if (theData.post_err || theData.email_err)
console.log('ak;dsfj');
})
}
}
The data is sent back to a function within a class... how can I handle the form elements within that scope? I'm looking for a way to trigger error codes in Angular on the appropriate form elements. How do I access them? Should I manually use document.getElementById or is there a more sophisticated approach?