Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
SwitchMap not triggering second API call

The below angular code switchMap is not working, I'm not sure what error I made. Under the switchMap second API call not triggering '/upload/file'

zip(
  this.service.submitForm(formValue),
  this.service.upload(fData)
).subscribe(
  ([submitForm, upload]) => {
    if (submitForm === 'success' && upload === 'Ok') {
      //Redirect confirmation page
    }
  },
  (err) => {
    console.log(err, 'ERORORO');
  }
)

//Service code
upload(formData): Observable <any> {
  return this.sessionService.keepAlive().pipe(
    switchMap(data => {
      let token = data.jwtToken;
      console.log(token, 'TOKEN SESSION');
      // getting output as Bearer xyz
      // with formData as req
      const request_config = {
        headers: {
          "Authorization": token
        }
      };
      console.log("REQUEST CONFIG", request_config); // getting output
      return this.http.post < any > (
        '/upload/file',
        formData,
        request_config
      ).pipe( // this is not working
        map((res) => {
          console.log(res, 'RESPONSE');
          return res.status;
        }),
        catchError((error: HttpErrorResponse) => {
          throw error;
        })
      )
    })
  )
}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda