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

169
Views
NodeJS/Express.js - Response contains different values each time after GET request

My goal is to develop a RESTful API with Express.js where a runtime parameter can be read-out and reset with HTTP methods. But I observe that the response values are not consistent.

I have tried to write the code which creates the inconsistency in the responses.

const express = require("express");
const app = express();
let init = 0;
let runtime = init;

setInterval( () => {
  runtime++;
}, 1000); // raise runtime value every 1000 ms

app.get("/runtime", (req, res) => {
  res.end(JSON.stringify(runtime))
});

app.post("/runtime", (req, res) => {
  runtime = init;
  res.end(JSON.stringify({"runtime": "reset to init"}))
});

In localhost, everything works fine line this:

Get /runtime : 1
Get /runtime : 2
Get /runtime : 3
Get /runtime : 4
Get /runtime : 5
…

As a deployed app (to AWS in a corporate environment), the inconsistency starts: After sending the post-method, I receive different values in the response to GET /runtime, the values. E.g. "12 s", then "9 s", then "14 s" then "12 s", so as if I was tapping into two different parameter values like runtime 1 and runtime 2:

Get /runtime : 1
Get /runtime : 2
Get /runtime : 3
Post /runtime : ok
Get /runtime : 5
Get /runtime : 1
Get /runtime : 7
Get /runtime : 3
Get /runtime : 9
Get /runtime : 5
…

Happy about every hint about why this observation occurs.

Thanks in advance!

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!