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

179
Visualizações
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 à 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