I'm encountering an issue with my Vue component where it fails to load due to one of its computed properties being undefined:
Error: Cannot read properties of undefined (reading 'map')
Here is the snippet of the computed property causing the problem:
artifacts() {
let projectArtifacts;
if (typeof this.currentProject !== 'undefined') {
const { artifacts } = this.currentProject.settings.artifacts;
projectArtifacts = Object.keys(artifacts).map((name) => ({
value: name,
labelText: this.convertValueToLabel(name),
}));
} else {
projectArtifacts = this.MIQAConfig.artifact_options.map((name) => ({
value: name,
labelText: this.convertValueToLabel(name),
}));
}
return projectArtifacts;
},
Upon inspecting Vue's DevTools, I can see that the array I need is present in Vuex store:
state
currentProject: Object
settings: Object
artifacts: Object
Test One: -1
Test Two: -1
In addition, within computed:
, I have:
...mapState([
'currentProject',
]),
What could be the mistake I am making in this scenario?