title: How to refresh React page/component on Button click after POST
body: <p>I want a table of data to refresh on button click <em>after</em> the POST request has been submitted.</p>
  
  <p>I have a react button:</p>
  
  <pre><code>&lt;Button onClick={this.click} className="domain-button" type='primary'&gt;Add&lt;/Button&gt;
  </code></pre>
  
  <p>And the corresponding <code>click</code> function, and <code>refreshPage</code> function:</p>
  
  <pre><code>async click() {
    const { domainInputValue } = this.state;
    console.log( domainInputValue );
  
    const response = await
    fetch('/new-cert', {
        headers: {
            'Content-Type': 'application/json'
        },
  
        method: 'POST',
        body: JSON.stringify({domainInput: domainInputValue})
    });
  
    const body = await response.text()
    console.log(body)
  
    if (response.status !== 200) throw Error(body.message);
    return body;
  }
  
  refreshPage() {
    window.location.reload();
  }
  </code></pre>
  
  <p>And in my back-end Nodejs to handle the POST request I have:</p>
  
  <pre><code>app.post('/new-cert', function (req, res) {
      fs.appendFile('certs-list', '\n' + req.body.domainInput, function (err) {
          if (err) throw err;
      });
      res.send('POST request: ');
  
      console.log("INSERTING")
      exec('sh cert-check-script-insert.sh');
  
      console.log(req.body);
      console.log('post is working!')
  });
  </code></pre>
  
  <p>I'm not sure where to call <code>refreshPage()</code>, I've tried calling it right after <code>click()</code> but this seems to be too early and the refresh does not change the data displayed in the table.</p>