Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

162
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda