error getting getter from an action of another vuex module Can not read property 'rootGetters' of undefined

0

When executing an action I get an error, in which I access getter that is in another module:

  

[TypeError: Can not read property 'rootGetters' of undefined]

For example, this action works and it calls the getter of the other module:

  ConsultarUsuario(context,data){
   console.log("entramos en consultarUsuarios");
    var bd  = context.rootGetters.GetBd;
    var sql = 'SELECT COUNT(PE_USU_ID)  FROM PERSONAS WHERE PE_CORREO=?;'
    var count=0;
    var mail = data["txtuser"]["text"];

    return new Promise((resolve,reject)=>{
       bd.all(sql,[data]).then(result=>{
          count=result[0][0];
          resolve(count);
       },error=>{
         reject("error en ConsultarUsuario" + error)
       });
    });
  },

but the next action is the one that gives me error

 InsertarSesionSqlite({context,dispatch},data){
  var array=[ data[0]["PE_USU_ID"],
              data[0]["PE_USU_ID"]

  ]
    var bd  = context.rootGetters.GetBd;
    var sql = 'INSERT INTO 'SESION' ( 'PE_USU_ID', SE_ESTADO)
             SELECT * FROM (?,1) as tmp
             WHERE NOT EXISTS (
                  SELECT ID_SESION FROM SESION WHERE SE_ESTADO=1 AND
                  PE_USU_ID=?
                  ORDER BY ID_SESION DESC
              )  LIMIT 1;'
       dispatch("InsertarUsuarioLite",data).then(result=>{
         console.log("entramos a llamado dispatch InsertarUsuarioLite")
         return new Promise((resolve,reject)=>{

               bd.execSQL(sql,[array]).then(result=>{
                  resolve(result)
               },error=>{
                 reject(error)
               });

         });
       }).catch(error=>{
         console.log("error al llamar dispatchs InsertarSesionLite " + error);
       });

 },

believe that it could be the order in which the parameters of the action are passed (context, dispacth, commit etc)

    
asked by jose miguel jara 26.10.2018 в 22:24
source

0 answers