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

703
Vistas
Catching Error in pipe() method of an Observable - rxjs/Axios

I refactored my http layer to go from a promised-based implementation to observables using rxjs. The problem that I am facing is that the code crashes whenever server response is 400 or 500,

Axios.request(config).pipe(map(((response: AxiosResponse) => response), catchError(e => {
    return new Observable(e);
})));

The problem I am facing is that the error is not being handled by the catchError callback. I am looking for a way in which the error is handled by the catchError callback so that the response can be handled gracefully.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I don't know your problem is this but you can do this:

import { EMPTY } from 'rxjs';

Axios.request(config).pipe(map(((response: AxiosResponse) => response), 
catchError(() => EMPTY)));

EMPTY is an object that is imported from rxjs libaray.

about 4 years ago · Juan Pablo Isaza Denunciar

0

It looks like you want to turn the error notification to next notification so you need to use return of(e) eventually EMPTY if you want to suppress the error.

new Observable(e) is probably what throws the error in your case because the parameter passed to Observable needs to be a function which e is not in this case.

about 4 years ago · Juan Pablo Isaza Denunciar
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