Answer the question
In order to leave comments, you need to log in
How to wait for the initial filling of the store before loading the page?
I need to authenticate the initial page load (that is, once, and not for each transition already inside the application) by requesting /api/init
, receiving a response, filling the store, and only then let the user in or not. I can not understand the earliest place in the View application where this can be done?
If I do this in main.js
, then the application does not wait for the result of the request.
Doing this in everyone beforeEnter
is not suitable, although it works, because. I only need it once when loading the page.
It doesn’t look very appropriate in a hook App.vue
, I want to move this logic to another place.
UPD: In a hook App.vue
, this is not suitable, because. The page is loaded without waiting for the end of the request.
But where?
Answer the question
In order to leave comments, you need to log in
In the App.vue hook, it doesn’t look very appropriate, I want to move this logic to another place.
There is an option to use SSR, where you can just implement a request to the api with filling the store, and only after that the application will start loading.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question