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

164
Views
Getting error handler data from post request in AXIOS

Can you tell me how can I consume a response from a post type request, in axios, which gives an error 422 (Unprocessable Entity)? I can't consume the JSON response from API, which would be, precisely, the error handling, with some information I need: example - { error: "ERROR_FROM_X_TO_Y" } (I'll need error attribute).

const postReq = () => {
  return async () => {
    try {
      const url = '/exampleUrl/account-data';
      try {
        const response = await axios.post(url);
      } catch (err) {
        console.log(err);
      }
    } catch (error) {
      console.log("error");
    }
  };
};

I already tried to console.log the response, but it doesn't works.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Actually the error is stocked in your response const, did you tried :

await axios.post(url).catch((err) => { console.error(err) });

Edit : I found out this issue on github, i hope she can be revelant for solve your problem :

axios.post('/formulas/create', {
            name: "",
            parts: ""
}).then(response => { 
      console.log(response)
    }).catch(error => {
      console.log(error.response)
    });
   

https://github.com/axios/axios/issues/960

over 4 years ago · Santiago Trujillo Report
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!