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

260
Views
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 answers
Answer question

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 Report
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!