0👍
You clearly have to use Vuex for this task.
You are sending your token from root to child components – are you going to add this property to every component that needs it? That’s why Vuex is needed. It synchronises the data across whole application.
Move all your token receiving logic to Vuex module, like this:
- Create token in Vuex state with initial value fetched from storage
- Create mutation that will set token to storage and set token in state
- Create action that will call API and pass token to mutation
- Create getter to use this token from Vuex
This is also explained here: https://scotch.io/tutorials/handling-authentication-in-vue-using-vuex
- [Vuejs]-I am using vue-date-pick for a calender input. But I want to disable all the previous dates expect today an upcoming dates
- [Vuejs]-How to assign a middleware to specific group of routes?
Source:stackexchange.com