title: Why does my webpage refresh after a NodeJS POST request?
body: <p>I'm using the express framework with NodeJS. When a client makes a POST request, it pushes some work off to a python script and then returns a JSON object to the client webpage.</p>
  
  <p>My problem is that the client refreshes whenever my POST request completes. I've tested with both the Axios and Fetch http clients. <strong>How do I prevent my webpage from refreshing when making a POST request like this?</strong></p>
  
  <p>The server code looks something like:</p>
  
  <pre><code>app.post("/data/", function(req, res) { 
  
      const spawn = require("child_process").spawn;
      const pythonProcess = spawn('python', ["my_script.py"]);
  
      pythonProcess.stdout.on('data', (data) =&gt; {
            let result = data.toString();
            res.send(JSON.stringify(result));
       });
  });
  </code></pre>
  
  <p>Then I make a request from my React client (using Axios, but Fetch behaves the same way):</p>
  
  <pre><code>axios({
    method: 'post',
    url: `http://localhost:3001/videos/?url=${url}`,
    responseType: 'json',
  });
  </code></pre>
  
  <p>And the client webpage refreshes...</p>
  
  <p>I know React isn't to blame, because nothing is updating the application state. Even if I do nothing with the response from the server, the webpage still refreshes when the POST completes.</p>
  
  <p>Also, there's no form element on my webpage or anything like that, and my <code>button</code> is of type <code>button</code> and not of type <code>submit</code>.</p>
  
  <p>I have a hunch it's something with the way that the python process itself is called, because if I just return a plain JSON object without calling a python subprocess, my client webpage gets the data and doesn't refresh.</p>