title: Can't access params sent in POST request from React client to Rails api
body: <p>I have a React Login component running on <code>localhost:3000</code>. It returns a form which, on submit, uses JS <code>fetch()</code> to post its information to SessionsController in a rails api which runs on <code>localhost:3001</code>. I've alternated between using a FormData object and custom json; I run into the same problems either way. I've gotten rid of CORS errors in the console by using 'rack-cors', but I'm still having problems accessing the posted information in my SessionController's <code>create</code> action. This is all I have in params when I throw a binding.pry into it:</p>
  
  <pre><code>[1] pry(#&lt;SessionsController&gt;)&gt; params
  =&gt; &lt;ActionController::Parameters {"controller"=&gt;"sessions", 
  "action"=&gt;"create"} permitted: false&gt;
  </code></pre>
  
  <p>------- How do I get hold of my username and password? ----------</p>
  
  <p>Login Component:</p>
  
  <pre><code>import React from 'react'
  const Login = () =&gt; {
    return(
      &lt;div&gt;
        &lt;h1&gt;Login&lt;/h1&gt;
        &lt;form id="login-form" onSubmit={(event) =&gt; postSession(event)}&gt;
          &lt;label htmlFor="username"&gt;Username &lt;/label&gt;&lt;br/&gt;
          &lt;input type="text" id="username"/&gt;&lt;br/&gt;
          &lt;label htmlFor="password"&gt;Password &lt;/label&gt;&lt;br/&gt;
          &lt;input type="password" id="password"/&gt;&lt;br/&gt;
          &lt;input type="submit" value="Login"/&gt;
        &lt;/form&gt;
      &lt;/div&gt;
      )
  }
  
  const postSession = (event) =&gt; {
    event.preventDefault()
    fetch('http://localhost:3001/sessions', 
      {
        header: {
          'Accept': 'application/json',
          'Content-Type': 'application/json'
      },
      method: 'post',
      body: new FormData(document.getElementById("login-form"))
      }
    )
      .then((response) =&gt; {console.log("Post Session Response: ", response)})
      .catch((error) =&gt; {console.log("Error in the Post Session fetch: ", error)})    
  }
  
  export default Login
  </code></pre>
  
  <p>config/application.js:</p>
  
  <pre><code>module Geohunter2
    class Application &lt; Rails::Application
      config.middleware.insert_before 0, "Rack::Cors" do
        allow do
          origins '*'
          resource '*', :headers =&gt; :any, :methods =&gt; [:get, :post, :patch, :options]
        end
      end
    end
  end
  </code></pre>