Get object value instead of observer type in Vuex module

Viewed 127

I'm trying to get the value from the Vuex module state inside the mutation. But I'm always getting the Observer object instead of a real object.

@Module({
    namespaced: true,
    name: 'myModule',
    dynamic: true,
    store
})

export class MyModule extends VuexModule {
    public users: ArrayToObjMap<Users> = {};

    @Action
    public async initialize() {
      const fetchedUsers = await UsersService.getUsers();
      this.context.commit('setUsers', fetchedUsers);
    }

    @Mutation
    public setUsers(usersList: string[]) {
      this.users = GlobalUtils.mapIdsToItems(usersList, this.users)[0];
    }
}

Inside setUsers Mutation, the value of this.users is always Observer. I need to get the simple object to iterate through. I've already tried several solutions:

  1. JSON.parse(JSON.strinfigy(this.users)); => returns empty object
  2. cloneDeep(this.users); => returns empty object
0 Answers
Related