So in my main.js file, I have the following set:
Vue.prototype.api_url = 'http://localhost'
and in one of my components: dashboard.vue
I am using the beforeRouteEnter
export default {
data() {
return {
}
},
beforeRouteEnter (to, from, next) {
axios.post(this.api_url + '/dashboard')
}}}
However, I get a TypeError: Cannot read property 'api_url' of undefined
On another component where I'm not using the beforeRouteEnter, I am able to access this.api_url without using an import statement at the component level.
Any thoughts or suggestions?