title: Fetch with Credentials and Json Body
body: <p>Need to send a <code>POST</code> request with a <code>JSON body</code>. I have to use <code>fetch</code>. </p>
  
  <p><strong>Original code snippet, which worked:</strong></p>
  
  <pre><code>headers = {'Content-Type': 'application/json'};
  body = {path: 'path1'};
  fetch(url, {
          method: 'post',
          headers: headers,
          body: JSON.stringify(body)
      })
          .then(response =&gt; {//do work});
  </code></pre>
  
  <p>Now I have to add <code>Http-Only cookies</code> for <code>A&amp;A</code>. </p>
  
  <p>This <a href="https://stackoverflow.com/a/40543547/398909">link</a> has answer for that. Basically, have to add another parameter. </p>
  
  <p><strong>Afterwards updated code to:</strong> </p>
  
  <pre><code>fetch(url, {
          credentials: 'include',
          method: 'post',
          headers: headers,
          body: JSON.stringify(body)
      })
          .then(response =&gt; {//do work});
  </code></pre>
  
  <p>Server doesn't see <code>cookie</code> in <code>header</code>. </p>
  
  <p>Then tested the <code>fetch</code> by removing everything else:</p>
  
  <pre><code>fetch(url, {
          credentials: 'include',
          method: 'post',
      })
          .then(response =&gt; {//do work});
  </code></pre>
  
  <p><code>A&amp;A</code> part works i.e. Server now sees <code>cookie</code> in <code>header</code>. So, added the body back and didn't believe it would work:</p>
  
  <pre><code>body = {path: 'path1'};
  fetch(url, {
          credentials: 'include',
          method: 'post',
          body: JSON.stringify(body)
      })
          .then(response =&gt; {//do work});
  </code></pre>
  
  <p>As expected, it didn't work. The <code>Express</code> server with <code>CookieParser</code> is showing that body is <code>{}</code>. </p>
  
  <p>After added the <code>Content-Type</code> header:</p>
  
  <pre><code>body = {path: 'path1'};
  fetch(url, {
          credentials: 'include',
          method: 'post',
          headers: {'Content-Type': 'application/json'}
          body: JSON.stringify(body)
      })
          .then(response =&gt; {//do work});
  </code></pre>
  
  <p>Now, the <code>cookie</code> has disappeared again. Guessing it's because of adding a new header, and replacing header generated by <code>fetch</code>, which includes <code>cookie</code>. Am I wrong? </p>
  
  <p>While I was searching I found a <a href="https://github.com/github/fetch/issues/452" rel="noreferrer">similar question</a> with no answer. </p>
  
  <p>How should I proceed?</p>