[Vuejs]-Vue axios not sending headers to server (django simplejwt)

0👍

OK, the problem comes from axios.get
I don’t know why, but it works when I use axios.create() and use intercepter to add headers with Authorization Token for every request.
Then I call axios_instance.get and then I can send my Token via headers.

0👍

Remove

SIMPLE_JWT = {
 

    'AUTH_HEADER_TYPES': ('Bearer',),
 
}

then call the function like this

test_auth: function(){

  var accessToken = this.$store.state.accessToken;
  console.log(accessToken);
  axios.get('http://django:8000/api/uvs/',{headers:{
    'Authorization':`Token ${accessToken}`,
    

  }} )
    .then(function (response) {
      console.log(response);
    })
    .catch(function (error) {
      console.log(error.response.data);
    });

},

Leave a comment