I am currently working on a small project and struggling to grasp certain TypeScript concepts. Specifically, I am trying to pass data from a form to an object and then send it via an HTTP service to an endpoint. The response is displayed in the console, indicating whether the operation was successful or if there was a validation error. My challenge now is figuring out how to retrieve and display these errors to the user using a popup. Any guidance on this matter would be greatly appreciated.
onSubmitRegistro(){
let formData: any = new FormData();
formData.append('email', this.usuario.email);
formData.append('password[first]', this.usuario.password1);
formData.append('password[second]', this.usuario.password2);
formData.append('userType', this.usuario.userType);
formData.append('reside', this.usuario.reside);
console.log(this.usuario);
this.http.post<Errores_ep>('http://54.220.205.31/api/users/register', formData)
.subscribe(data => {
console.log(data);
});
}
My main concern is presenting real-time updates on the screen. For instance, when the API reports that the email address already exists,
here's a screenshot for reference.
I have attempted to watch videos on observables and HTTP error handlers, but I am still uncertain about which method to use and how to implement it correctly.