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

218
Vistas
Refreshing a page fail to send a request to express server

So I have an express server configured to send the below html page upon request:

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="../style.css">
    <title>My Title</title>
</head>
<body >
    <div id="state">
        <p></p>
    </div>
    <script>
        const urlParams = new URLSearchParams(window.location.search);
        const dateparam = urlParams.get('date');
        function loadDoc() {
            fetch('http://my_machine_name:5000/wa/send/api?date=' + dateparam).then(response => response.json()).then(post => {
                document.getElementById("state").innerHTML = post.htmltext;
                const interv = setInterval(loadState, 1000);
            });
        }
 
        function loadState() {
            fetch('http://CLINIC:5000/api/update').then(response => response.json()).then(post => {
                document.getElementById("state").innerHTML = post.htmltext;
                if (post.finished) {
                    clearInterval(interv);
                };

            });
        }
        window.onload = "loadDoc()"
    </script>

</body>
</html>

here is the node js code to send the html page:

app.get('/wa', function (req, res) {
  const report = req.query.report;
  if (report) {
    res.sendFile(path.join(__dirname, '/report.html'));
    console.log('report requested')
  }
  else {
    res.sendFile(path.join(__dirname, '/send.html'));
  }
});

Every thing works fine, except when I refresh the report html page, when I do that nothing happens, and in fact a request is never made to the server, and when I examine the network tab of the developer's tool in chrome I see a request for this URL 'http://my_machine_name:5000/wa/send/api?date=2021-1-1&report=true', with pending status, so the request is correct, I don't understand why it is not transfered to the server? If however I cancel the refresh and press enter on the address bar the request is sent and every thing works fine once more, so it is just a refresh thing. I'm testing this on my local windows server machine if that matters.

Thank you very much.

about 4 years ago · Juan Pablo Isaza
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