Scenario
First of all, let me start with my flow.
I am storing token in localStorage (I know I shouldn't do it.) Then, whenever my Nuxt App is started, I want to fetch token from localStorage, verify it using API call, and initialise state accordingly.
Problem
I am using Server Side Rendering and Nuxt initialises state Server Side. Thus, localStorage is not accessible there.
Proposed Workaround
I created an Action which does task explained in Scenario
and that action is triggered from mounted() of layouts/default.vue
Can Anyone Please suggest a Better Workflow or Can Verify Wether this is Correct Way of doing things?
Aucun commentaire:
Enregistrer un commentaire