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

185
Visualizações
I can't reach the catch block of the try-catch method

I'm sending a base64 string to a backend with axios, but it can only be sent if the string is not over 2MB long. if it's longer than that I want to console.log the error message, but it doesn't work - because I can't reach the catch block of the try-catch. I see an error message in the console that says I can't send it because the payload is too large, but I don't see the error message I tried to console.log. It's really important because in addition I want to change some state inside the catch block, but I just can seem to reach it.

const base64image = JSON.stringify({long base64 string of encoded image})
  try {
      axios
        .post(
          'someurl',
          base64image,
          {
            headers: {
              'Content-Type': 'application/json',
            },
          }
        )
        .then((res) => {
          console.log(
            'success ' + JSON.stringify(res.data)
          );
        })
        .catch((err) => {
          if (err.res) {
            console.log('failure: ' + err.res.data.message);
          }
        });
    } catch (e) {
      console.log(e);
    }
  };
about 4 years ago · Juan Pablo Isaza
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