title: How to post object using fetch with form-data in React?
body: <p>I want to send a file to my express app as backend. My problem is that my body is send as type <code>application/json</code> and I want to send this as a <code>form-data</code> and later upload this file using <code>multer</code> -> <a href="https://github.com/expressjs/multer" rel="noreferrer">https://github.com/expressjs/multer</a></p>
  
  <p>I don't know how to prepare fetch call to get it later in express. </p>
  
  <pre><code>    fetch('/api/data', {
    method: 'POST',
    headers: {
      Accept: 'application/form-data',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(data),
  })
    .then((resp) =&gt; resp.json())
    .then((data) =&gt; console.log(data));
  </code></pre>
  
  <p>When I want to log <code>req.file</code> in api breakpoint I'm getting <code>undefined</code>.</p>
  
  <pre><code>app.post('/api/data', upload.single('cv'), (req, res) =&gt; {
    console.log(req.body);
    console.log(req.file);
    res.send({ name: 'Hello world!' });
  });
  </code></pre>
  
  <p>I store react data from form using hooks and this object looks like this: </p>
  
  <pre><code>{
     name: 'test',
     surname: 'test2',
     cv: 'C:\\fakepath\\Babel error.png'
  }
  </code></pre>