title: When making a POST with fetch() TypeError: Failed to fetch is thrown without waiting on the response
body: <p>I have a front end form that posts data using <code>fetch()</code>. Requests work properly and give the appropriate response when the server is allowed to run without any interruptions. When I debug the server endpoint the request is being made to <code>TypeError: failed to fetch</code> is thrown. </p>
  
  <p>Its not a cors issue since the request is resolved correctly when the breakpoint is removed from the api. </p>
  
  <pre><code>exports.add_new_data = async (req, res, next) =&gt; {
    promise = db.addData(req.body.data); //this is where I have the breakpoint and pause
    promise
      .then((data) =&gt; {
        res.status(201).send({
          success: true,
          message: "Data added successfully",
          error: null,
          data: data,
        });
      })
      .catch((err) =&gt; {
        res.status(500).send({
          success: false,
          message: err.message,
          error: err,
        });
      });
  };
  </code></pre>
  
  <p>and this is the front end code</p>
  
  <pre><code>render() {
    return (
      &lt;div&gt;
        &lt;form&gt;
          &lt;label htmlFor="Name"&gt;Name: &lt;/label&gt;
          &lt;input id="Name" type="Text" onChange={this.updateName} /&gt;
          &lt;label htmlFor="Age"&gt;Age: &lt;/label&gt;
          &lt;input id="Age" type="Text" onChange={this.updateAge} /&gt;
          &lt;button onClick={this.submit}&gt;submit&lt;/button&gt;
        &lt;/form&gt;
      &lt;/div&gt;
    );
  }
  submit = async () =&gt; {
    try {
      let data = [];
      data.push({ name: this.state.name, age: this.state.age });
      let res = await fetch(`${d}/people/add-person`, {
        // Error immediately thrown here
        method: "POST",
  
        headers: {
          "Content-Type": "application/json",
        },
        body: JSON.stringify({ data }),
      });
      let data = await res.json();
      alert(`Status ${res.status}`);
      if (res.status === 200) {
        alert("Added Successfully");
      } else {
        alert(`${data}`);
      }
    } catch (error) {
      alert(error);
    }
    alert(`Name: ${this.state.name} Age: ${this.state.age}`);
  };
  </code></pre>