Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

258
Views
¿Cómo hacer el aplanamiento en Rxjs para el servicio de autenticación angular?

Creé un servicio de autenticación en Angular con la función SignUp que envía la solicitud de API a Firebase. Como Firebase devuelve la ID de usuario, estoy guardando la ID de usuario en mi base de datos MongoDB personal con su función. Ahora, el problema aquí es que estoy enviando dos solicitudes que quiero suscribir más en Register.component.ts, no puedo entender cómo lograr esto. A continuación se muestra el código de muestra que he probado.

auth.service.ts

 signUp(email: string, password: string) { return this.http.post<AuthResponse>(`https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=${config.API_KEY}`, { email: email, password: password, returnSecureToken: true }).pipe( switchMap(data => { return this.http.post<any>(`${config.BASE_URL}/api/ezusers/`,{useruid: data.idToken, 'isRegistered':false}); // or this.userId }) ).map(response => { this.authenticatedUser(response.email, response.localId, response.idToken, +response.expiresIn); // this.userOrders = response; return });

}

Registrar.componente.ts

 onSubmit() { this.loading = true; if (this.registerForm.valid) { this._authService.signUp(this.registerForm.value.email, this.registerForm.value.password).subscribe( res => { console.log(res); this.loading = false; this.registerForm.reset(); this.success = true; this.error = false; }, err => { console.log(err); this.loading = false; this.success = false; this.error = this.errMsgs[err.error.error.message]; }) } else { }

}

Cualquier ayuda sería realmente apreciada.

¡Gracias de antemano!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No entiendo totalmente lo que quiere lograr en el componente de registro, pero he notado que la respuesta siempre será falsa, ya que regresa indefinido en el servicio. No estoy seguro de qué método devuelve el usuario autenticado, pero inténtelo.

 signUp(email: string, password: string) { return this.http.post<AuthResponse>(`https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=${config.API_KEY}`, { email: email, password: password, returnSecureToken: true }).pipe( switchMap(data => { return this.http.post<any>(`${config.BASE_URL}/api/ezusers/`,{useruid: data.idToken, 'isRegistered':false}); // or this.userId }) ).map(response => this.authenticatedUser(response.email, response.localId, response.idToken, +response.expiresIn) );
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!