Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

180
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!