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

161
Visualizações
Why any http response with status code different of 200 axios gets response undefined

So I'm developing a c# API that returns some status codes, and this is my function on controller:

public IHttpActionResult validateToken(HttpRequestMessage request, string token)
{
        bool result = AuthUser.validateToken(token);

        if (!result)
        {
            return BadRequest();
        }
        else
        {
            return Ok();
        }
}

Then I have my axios to make the requests:

    this.$axios.get("validateResetToken/" + token)
      .then((response) => {
        console.log(response)
      })
      .catch((error) => console.log(error));

And when the API returns the 200, Ok(), the response gives me a object:

enter image description here

But when the return is anything than Ok [ 200 ], the response is always undifined and I cant figure it out why.

enter image description here

Why cant I have always a response, to get the status code, in this case 200 or 400.

about 4 years ago · Juan Pablo Isaza
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