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

219
Views
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
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!