This guide has been invaluable, thank you. Just one thing I'm trying to puzzle out - what is the purpose of the beforeCreate() code here? Is there a reason to prefer this over injecting the Axios instance in the Vue prototype?
Vue.prototype is shared between all Vue instances, what will result in a single axios instance to all Vue instances (a singleton).
But in that particular case, a singleton can mess with our autentication logic, since that is being handled into the axios interceptor and this reads the token from the Cookies plugin, what isn't a singleton, what can lead to a data leak.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This guide has been invaluable, thank you. Just one thing I'm trying to puzzle out - what is the purpose of the
beforeCreate()code here? Is there a reason to prefer this over injecting the Axios instance in the Vue prototype?Vue.prototypeis shared between allVueinstances, what will result in a singleaxiosinstance to allVueinstances (a singleton).But in that particular case, a singleton can mess with our autentication logic, since that is being handled into the
axiosinterceptor and this reads the token from the Cookies plugin, what isn't a singleton, what can lead to a data leak.