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

170
Vistas
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
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