M
M
Max Zhukov2018-07-24 00:23:04
Vue.js
Max Zhukov, 2018-07-24 00:23:04

How to delay the main App component when loading the user from the api?

I use vuex, I load it through firebase user and put it in vuex, when the page is reloaded, the user gets null, how to wait for the user to load to render the page, or maybe there are other options? I put the data in localstorage, but keeping the whole user there is not an option, I only store the token.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2018-07-24
@MaksZhukov

Where user data is required, use conditional rendering: If user is needed everywhere, then first load it, and then initialize the application:
<нельзя-рендерить-без-user v-if="user">

store.dispatch('заргузитьДанныеПользователя').then(() => {
  new Vue({ ... });
});

J
Jhn Doe from, 2018-07-24
@spbislanders

If I understood the question correctly https://stackoverflow.com/questions/48009624/vuejs...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question