No tienes acceso a esta clase

¡Continúa aprendiendo! Únete y comienza a potenciar tu carrera

Flujo de registro

4/20
Recursos

Aportes 3

Preguntas 2

Ordenar por:

¿Quieres ver más aportes, preguntas y respuestas de la comunidad?

Para enviar mostrar el error de usuario que ya existe:

...    
        },
        error: (error) => {
          if (error.error.code === 'SQLITE_CONSTRAINT_UNIQUE'){
            this.message = 'This user already exists. Do you want to Login?';
          }
          this.status = 'failed';
          console.log(error);

        }

Dado que tenia el siguiente mensaje en mi editor de codigo

@deprecated — Instead of passing separate callback arguments, use an observer argument.

Cambie el codigo de esto:

this.authService.register(name, email, password,)
.subscribe(
          (response) => {
            console.log(response);
            this.status = 'success';
            this.router.navigate(['/auth/login']);
          },
          (error) => {
            console.log(error);
            this.status = 'failed';
          }
        );

A esto:

this.authService.register(name, email, password,)
        .subscribe({
          next: (response) => {
            console.log(response);
            this.status = 'success';
            this.router.navigate(['/auth/login']);
          },
          error: (error) => {
            console.log(error);
            this.status = 'failed';
          }
        });
Mi metodo register en el service:  ```js register(name: string, email: string, password: string) { return this.http .post(`${this.apiUrl}/api/v1/auth/register`, { name, email, password }) .pipe( catchError((error) => { //console.log("errror from service ", error) if (error.error.code === 'SQLITE_CONSTRAINT_UNIQUE') { return throwError('El usuario ya existe'); } return throwError('Ups algo salio mal'); }) ) } ```