title: javascript fetch() works with breakpoints, but fails with TypeError when run normally
body: <p>I'm trying to fetch() text/plain data from a remote service. If I place a breakpoint in the promise "then" chain, the text data from the server is available. Without the breakpoint, I get a fetch() exception. </p>
  
  <p>I am using a prototype design pattern (see below). When I place a breakpoint in the "then" chain as shown below, the data from the remote service is successfully retrieved. Without the breakpoint, the catch() is executed and the error is:</p>
  
  <pre><code>TypeError: Failed to fetch
  </code></pre>
  
  <p>I'm totally stumped and would appreciate any help!</p>
  
  <p>Note, the server (a python app) sends back html, with </p>
  
  <pre><code>self.send_header("Access-Control-Allow-Origin", "*")
  </code></pre>
  
  <p>Also, if I use Ajax (FWIW, it works). I'd like to get it working with fetch() however.</p>
  
  <pre><code>function Fetch(Msg) {
     // Msg contains some info on how to construct the JSON message to transmit -- not relevant here.
      this.help = `
          The Fetch object specifies communication basics using
          the fetch(...) mechanism. 
      `;
      // some misc object vars...
  }
  
  Fetch.prototype = {
      constructor: Fetch,
  
      postData: async function (url = '', data = {}) {
          const response = await fetch(url, {
              method:         'POST,
              mode:           'cors',
              cache:          'no-cache',
              credentials:    'same-origin',
              headers: {
                  'Content-Type': 'text/plain',
              },
              redirect:       'follow',                   
              referrerPolicy: 'no-referrer',              
              // body data type must match "Content-Type" header
              body: JSON.stringify(data)
          });
          return await response.text(); // 
      },
  
      handleErrorsInResponse: function (response) {
          var debug = new Debug("Fetch.handleErrorsInResponse");
          debug.entering();
          debug.leaving();
      },
  
      handleReponse: function (response) {
          var debug = new Debug("Fetch.handleResponse");
          debug.entering();
          console.log(response);
          debug.leaving();
      },
  
      handleErrorsInFetch: function (response) {
          var debug = new Debug("Fetch.handleErrorsInFetch");
          debug.entering();
          console.log(response);
          debug.leaving();
      },
  
      call: function (payload) {
          this.postData(
              'http://some.url/',
              payload)
          .then(this.handleErrorsInResponse)  // If I place a breakpoint here it works!
          .then(this.handleReponse)
          .catch(this.handleErrorsInFetch);
      },
  }
  
  // Ultimately called by something like
  comms = new Fetch();
  someData = {"key": someJSON};
  comms.call(someData);
  
  </code></pre>