title: Uncaught (in promise) TypeError: Failed to fetch and Cors error
body: <p>having a problem with getting data back from database. I am trying my best to explain the problem.</p>
  
  <p>1.If I leave "mode":"no-cors" inside the code below, then I can get data back from server with Postman, but not with from my own server. Thinking it has to be my client side error</p>
  
  <ol start="2">
  <li>When I remove "mode":"no-cors" then I am getting 2 errors:
  -Fetch API cannot load <a href="http://localhost:3000/" rel="noreferrer">http://localhost:3000/</a>. Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response.
  -Uncaught (in promise) TypeError: Failed to fetch</li>
  </ol>
  
  <p>Quick Browsing suggested to put in the "mode":"no-cors" which fixed this error, but it does not feel right thing to do.</p>
  
  <p>So I thought maybe somebody has a suggestion how to approach this problem.</p>
  
  <p>Really hope I was clear enough, but pretty sure I am not giving clear explanation here :S</p>
  
  <pre><code>function send(){
      var myVar = {"id" : 1};
      console.log("tuleb siia", document.getElementById('saada').value);
      fetch("http://localhost:3000", {
          method: "POST",
          headers: {
              "Access-Control-Allow-Origin": "*",
              "Content-Type": "text/plain"
          },//"mode" : "no-cors",
          body: JSON.stringify(myVar)
          //body: {"id" : document.getElementById('saada').value}
      }).then(function(muutuja){
  
          document.getElementById('väljund').innerHTML = JSON.stringify(muutuja);
      });
  }
  </code></pre>