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

173
Vistas
Can an Ajax call get a token and retry itself after a 401

The ajax call needs a token that expires frequently. There is no external process to periodically fetch a new token so I'm stuck. What I'd like to happen in this scenario when it's expired is: 1.Function fails 2.Fail case executes a new call to get a new token 3. Original Ajax call tries again, this time with a good token. Below is what I have:

$.ajax({
    method: "GET",
    url: myUrl,
    headers: { "Authorization": "Bearer " myToken}
    })
    .done(function(data, statusText, xhr){
        //All good here
    })
    .fail(function (xhr, response){
        if(xhr.status == 401){

             //Here is where I'm looking to find a solution
             //First get new token here ex. function getToken()
             //Next retry above function


        }
    });
over 4 years ago · Santiago Trujillo
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