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

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

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