Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

702
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda