Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

194
Vistas
getters return a function in mutation vuex in vue js

I am working on a project that has already started and my problem is the following:

I have a mutation, which will render a menu, depending on whether the user has permission to access or not, this is calculated with a getter.

let menuList = [];
appRouters.forEach(item => {
  // eslint-disable-next-line no-console
  if (item.permission !== undefined) {
    let hasPermissionMenuArr = [];
    hasPermissionMenuArr = item.children.filter(child => {
      if (child.permission !== undefined) {
        //if (child.permission.includes('operator')) {
        console.log(hasPermission(child.permission))
          if (hasPermission(child.permission))  {
          return child;
        }
      } else {
        return child;
      }
    });

The code would "work" fine, but when it goes to access the getters to check if the user has permission to that menu, the getters that one returns the function it has to receive parameters, and not the value.

export const hasPermission = state => permission => {
return isGranted(state, permission);
};

here the other function of the getter

function isGranted(state, permissionName) {
  return (
    state.user !== undefined &&
    state.user.roles !== undefined &&
    state.user.roles.some(p => {
      return p.toLowerCase() === permissionName.toLowerCase();
    })
  );
}

I know that the getter is calling a third function, but even, to the hasPermission getter I have only put a return of a console.log of the permission that is passed to it, and even then it returns the function in text.

I know there is something that I do not understand

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda