title: Set proxy for XMLHttpRequest to edit form data
body: <p>How can I edit all POST requests from a client? My research says that it should be possible with a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy" rel="nofollow noreferrer">proxy object</a> on XMLHttpRequest. How can I inspect a POST request and edit the form data before it gets sent to the server?</p>
  
  <p>I've tried <a href="https://stackoverflow.com/questions/4809342/how-can-i-create-a-xmlhttprequest-wrapper-proxy">this</a> approach but the data getting sent through is just responses.</p>
  
  <pre><code>var _XMLHttpRequest = XMLHttpRequest;
  XMLHttpRequest = function() {
      var xhr = new _XMLHttpRequest();
  
      // augment/wrap/modify here
      var _open = xhr.open;
      xhr.open = function() {
          // custom stuff
          return _open.apply(this, arguments);
      }
  
      return xhr;
  }
  </code></pre>