[Vuejs]-Add axios authorization on nuxt config

3👍

Try this, taken from the module docs.

axios: {
  headers : {
    common: {
      'Authorization' : '5fb9c42ceba425fb9c42ceba43'
    }
  }
}

2👍

I have created an plugin for it. Goto plugins and create axios.js:

export default function ({ $axios, store }) {
  if (process.client) {
    $axios.setToken(store.state.appstore.akey, 'Bearer')
  }
}

Then register your plugin in nuxt.config.js

plugins: ['@/plugins/axios'],

Leave a comment