vue-wait icon indicating copy to clipboard operation
vue-wait copied to clipboard

Use vue-wait with vue-router and beforeRouteEnter

Open ahoiroman opened this issue 4 years ago • 1 comments

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?

ahoiroman avatar Feb 25 '20 16:02 ahoiroman

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.

ThomasKuhlmann avatar Apr 06 '20 17:04 ThomasKuhlmann