Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3694

Sending the bearer token with axios

$
0
0

In my react app i am using axios to perform the REST api requests.

But it's unable to send the Authorization header with the request.

Here is my code:

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

Here the validToken() method would simply return the token from browser storage.

All requests are having a 500 error response saying that

The token could not be parsed from the request

from the back-end.

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


Viewing all articles
Browse latest Browse all 3694

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>