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

255
Vistas
Axios GET Request - Date.now() does not change value

Im doing GET requests via Axios on NODE and one of the headers for the method has to contain timestamp, everything works except that timestamp does not change value after the first time its initialized.

Because the timestamp does not change that causes some issues with receiving the response after a certain amount of time.

let time = Date.now().toString()

headers: { "timestamp": time }

Because the time is also used for encryption of other variables sent via the request, the timestamp used for encryption and for headers has to be the same.

headers: { "timestamp": Date.now().toString() } Does not work.

This is my first post on StackOverFlow, I have no clue if any of this makes sense.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

headers: { "timestamp": Date.now().toString() } should work, but as you said it's not working so try this workaround:

{
    let time = Date.now().toString(); 
    // insert your axios code here
    // headers: { "timestamp": time }
}

{
    let time = Date.now().toString();
    // insert your encryption code here
}

The two time variables don't conflict with each other because they were initialised with let and only exist in their current scope, which is between the curly brackets. This code uses two variables, so the Date.now() function is called twice and therefore updates for the two different things you're doing.

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