When getting Data from a VueX Module via Getter the Object is wrapped with a Proxy that throws following error:
TypeError: attempted to get private field on non-instance
when trying to read a private property with a public getter.
class Example {
#privateField;
get privateField() {
return this.#privateField;
}
}
computed(){
getInfoForSpecificItem() {
const arrayOfInstantiatedExamples = this.$store.getters['getArrayOfInstantiatedExamples'];
for (let i = 0; i < arrayOfInstantiatedExamples.length; i += 1) {
// trying to access it in this condition throws the error since the Object
// has been wrapped with a Proxy coming from Vue (I guess)
if (arrayOfInstantiatedExamples[i].privateField === 'something') {
// does something
}
}
}
}
Why am I not able to read the property, and how can I create an instance from the proxy target. logging the Proxy Object reveals, that the target has all information, yet trying to read it via getter doesn't work.
Are there any other options than making the fields public?