title: React js - Laravel 5: Using csrf-token in POST method
body: <p>I've read some questions about Laravel's CSRF, but I still haven't found how to use it with React.
  My goal is to make a POST form, where I make an AJAX call.</p>
  
  <p>Here is an extract of my <code>render( )</code>.</p>
  
  <pre><code>render() {
  return (
    &lt;form method="post" action="logpage"&gt;
     &lt;input type="hidden" name="csrf-token" value="{{{ csrf_token() }}}" /&gt;
     //I'm sure this doesn't have csrf_token.
  
     &lt;input type="text" name ="word" value={this.state.word || ''}/&gt;
     &lt;button onClick={this.submit} className="btn btn-flat btn-brand waves-attach waves-effect" data-dismiss="modal" type="button"&gt;Save&lt;/button&gt;
    &lt;/form&gt;
    );
  }
  </code></pre>
  
  <p>Here is the submit function.</p>
  
  <pre><code>submit(){
  fetch('/words', {
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json',
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    body: JSON.stringify({
      //parameters
    })
  }).then((response)=&gt;{
    console.log(response);
  });
  }
  </code></pre>
  
  <p>The problem, I assume, is that <code>$('meta[name="csrf-token"]').attr('content')</code> is not being sent, because the token isn't generated. However, I don't see how I can generate it on React. </p>
  
  <p>Does anyone have an idea?</p>