A
A
AE422020-06-09 18:06:44
Vue.js
AE42, 2020-06-09 18:06:44

How to fix data loading?

Hello everyone

I have a project on nuxtjs

I have an isAuth middleware that checks whether the user is authorized (that is, whether the data has arrived)
The data is stored in the store, in layout/default.vue, using the created hook I do dispatch('user') to send a request to get data

. What is the problem
? When I set middleware: 'isAuth' on any page and reload it, then I get a redirect to the main page (such a condition in the middleware)
If I go from the main page to the page where I have middleware: 'isAuth', then everything works fine

How can I fix this so that the middleware waits for the data to load?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vearodev, 2020-06-09
@Vearodev

https://nuxtjs.org/guide/vuex-store/
What you need is nuxtServerInit

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question