Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use vue-wait with vue-router and beforeRouteEnter #87

Open
ahoiroman opened this issue Feb 25, 2020 · 1 comment
Open

Use vue-wait with vue-router and beforeRouteEnter #87

ahoiroman opened this issue Feb 25, 2020 · 1 comment

Comments

@ahoiroman
Copy link

Hello everybody,

actually I'd like to use vue-wait with vue-router and beforeRouteEnter

If I'm doing something like

        beforeRouteEnter (to, _from, next) {
            const promises = [
                axios.get ('/api/user/1'),
            ];

            this.$wait.start('loading.users');

            axios.all (promises)
            .then (([userRes]) => {
                next ((vm) => {
                    vm.user = userRes.data.data;
                });
            });
        },

I am getting an error

TypeError: undefined is not an object (evaluating 'this.$wait')
beforeRouteEnter — ....js

So how could I solve this?

@ThomasKuhlmann
Copy link

this isn't available in the beforeRouteEnter guard, but that's a general Vue limitation - check out the Vue router docs, they talk about this and the solution in more detail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants