I'm using axios. It needs the Authorization header with bearer token on every request. The token is in the store.
import axios from 'axios'
let instance = axios.create({
baseURL: 'http://api.docstore.dev'
})
instance.interceptors.request.use(config => {
// How can i access this store instance below
config.headers['Authorization'] = 'Bearer ' + store.state.accessToken
return config
})
export default instance
Thank you!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
https://github.com/nuxt-community/modules/issues/89#issuecomment-318107891