title: Using JavaScript Fetch with Formidablejs, Expressjs
body: <p>I'm using Reactjs saga to send a post request using fetch. Also I'm trying to use formidable instead of usual body-parser. I'm getting weird parsing issues. What am I doing wrong?</p>
  
  <pre><code>// saga simplified piece of code
  const { loginEmail, loginPwd } = request.payload;
  
  let postLoginSubmitOptions = {
    method: "POST",
    headers: {
      'Accept': 'application/json, application/xml, text/plain, text/html, *.*',
      'Content-Type' : 'application/x-www-form-urlencoded'
    },
    body: JSON.stringify({
      loginEmail: loginEmail,
      loginPwd: loginPwd
    })
  };
  
  const response = yield call(fetch, `http://www.example.com/register`, postLoginSubmitOptions);
  
  // expressjs side, simplified view
  
  router.post('/register', function(req, res, next) {
    console.log('registering user');
  
    var form = new formidable.IncomingForm();
  
    form.parse(req, function(err, fields, files) {
      if(err){
        console.log(err);
      }
      console.log(`incoming fields via form parse`);
      console.log(fields); // { '{"loginEmail":"my-email@gmail.com","loginPwd":"my-password"}': '' }
      console.log(fields.loginEmail); // undefined
    });
  
    }
  </code></pre>