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:
JSON.parse(JSON.strinfigy(this.users));
=> returns empty objectcloneDeep(this.users);
=> returns empty object