Sending the bearer token with axios
<p>In my react app i am using <a href="https://github.com/mzabriskie/axios" rel="noreferrer">axios</a> to perform the REST api requests.</p>

<p>But it's unable to send the <em>Authorization</em> header with the request.</p>

<p>Here is my code:</p>

<pre><code>tokenPayload() {
  let config = {
    headers: {
      'Authorization': 'Bearer ' + validToken()
    }
  }
  Axios.post( 
      'http://localhost:8000/api/v1/get_token_payloads',
      config
    )
    .then( ( response ) =&gt; {
      console.log( response )
    } )
    .catch()
}
</code></pre>

<p>Here the <code>validToken()</code> method would simply return the token from browser storage.</p>

<p>All requests are having a 500 error response saying that </p>

<blockquote>
  <p>The token could not be parsed from the request</p>
</blockquote>

<p>from the back-end.</p>

<p>How to send the authorization header with each requests? Would you recommend any other module with react?</p>