Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

251
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda