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

178
Vistas
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 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