Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
¿Puede una llamada Ajax obtener un token y volver a intentarlo después de un 401?

La llamada ajax necesita un token que expire con frecuencia. No hay un proceso externo para obtener periódicamente un nuevo token, así que estoy atascado. Lo que me gustaría que sucediera en este escenario cuando haya expirado es: 1. La función falla 2. El caso de falla ejecuta una nueva llamada para obtener un nuevo token 3. La llamada Ajax original intenta nuevamente, esta vez con un buen token. A continuación se muestra lo que tengo:

 $.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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!