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

231
Vistas
How to prevent/handle auto redirection on api calls with fetch

I am trying to access the api but for accessing the api I need token so When I try to hit the api it redirects to the auth page.

I can see the redirection is happening in the network tab.

is there any way to prevent this?

I wanted to get the 302 error code when I first hit the api(its giving 302 but with fetch/Redirect) but because of automatic redirection its throwing error and going to error block always.

fetch(url, { method: 'POST', redirect: 'error'})
.then(response => {
    // handle 302 response
})
.catch(function(err) {
    console.info(err);
});

Edit: To get the token I need to redirect user to the auth page. so once I get the 302 error Ill redirect the user to the auth page.

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