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

179
Visualizações
get the array value from an api response

SO I think I am having a brain fart, I am trying to get the values for these three different error responses.

message validation

{
  "errors": [
    {
      "message": "Validation failed for the field [confirmAppointment].",
      "extensions": {
        "validation": {
          "input.birth_date": [
            "The input.birth date must be a date before today."
          ]
        },
        "category": "validation"
      },
      "locations": [
        {
          "line": 1,
          "column": 11
        }
      ],
      "path": [
        "confirmAppointment"
      ]
    }
  ],
  "data": {
    "confirmAppointment": null
  }
}

I get this response during an axios catch, id like to display this msg back to the user during validation, however, I think I am having a brain fart.

So far I tried this:

let result = err.response.data.errors.extensions.map(a => a);

This gives me the array of object

enter image description here

any Ideas?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Your code:

let result = err.response.data.errors.extensions.map(a => a);

extensions is an object. errors is an array, so you need to:

let result = err.response.errors.map(a => a);
about 4 years ago · Juan Pablo Isaza 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