[Vuejs]-Unauthorized access : api token Vue to flask

0👍

You can set http headers using config,

 // where populate secret-token-1 from cookies or available web resources
Vue.http.headers.common['Authorization'] = 'Token secret-token-1';

it will send header for every requests, if you are using vue-resource
for sending header for specific request,

  this.$http.get('/api/name', function(node) {
   //  handle response
  }, {headers: {'Authorization': 'Token secret-token-1'}});

Note: use a common functions like get_authtoken, where i hard coded the token 🙂

Leave a comment