Works fine in dev mode, but after build process vue not includes setupToken function (from @/api.js) to app.js output file.
// App.vue
//...
import { setupToken } from '@/api
export default {
mounted () {
this.setupToken() // TypeError: this.setupToken is not a function
}
}
// @/api.js
import { mande } from 'mande'
export const postsAPI = mande(`${process.env.VUE_APP_ROOT_URL}/api/v1/posts`)
export const setupToken = ({ token }) => {
postsAPI.options.headers.Authorization = 'Bearer ' + token
}
I guess the problem with webpack config (im using default one), but not sure how to fix it.