samedi 26 juin 2021

Uncaught (in promise) TypeError: middleware[0] is not a function | Vuejs CLI | Version: 3.0.7

I am creating a dynamic middleware where middleware contains middleware function name. but it is generating the error as in title.

    if (to.meta.middleware){
        const middleware = Array.isArray(to.meta.middleware)?to.meta.middleware:[to.meta.middleware]
        const context = {
            from,
            next,
            router,
            to
        }
        const nextMiddleware = nextFactory(context, middleware, 1);
        return middleware[0]({context, next:nextMiddleware});
    }
return next();
})```



Aucun commentaire:

Enregistrer un commentaire