title: React js can't fetch api from localhost
body: <p>I am getting this error when trying to send post request using my localhost api :</p>
  <pre><code>Access to fetch at 'http://127.0.0.1:8000/my-api/' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
  </code></pre>
  <p>here is my code:</p>
  <pre><code>const SubmitContact = async (e)=&gt;{
      e.preventDefault()
      const contact = {contact_name,contact_email,contact_body}
      fetch(&quot;http://127.0.0.1:8000/my-api/&quot;,{
        method: &quot;POST&quot;,
        header: {
          &quot;Accept&quot;: &quot;application/json&quot;,
          &quot;Content Type&quot;:  &quot;application/json&quot;,
        },
        body: JSON.stringify(contact)
      }).then((result)=&gt;{
        console.warn(result)
      })
    }
  </code></pre>
  <p>Why I can't send post request where I am doing mistake? my api also working in <strong>post man</strong> so I think I might be doing any mistake in my javascript code.</p>