A.vue
<script>
import {pathdata} from "../../assets/pathdata";
data() {
return {
pathdata: [],
};
},
mounted() {
pathdata().then((r) => {
this.matchingData = r.data;
});
},
}
</script>
List.vue
<template>
<div>
<div v-if="matchingData.length > 0" class="line">
<div
v-for="match in matchingData"
:key="match.PipelineID"
:class="{
green: match.OverallStatus === 'healthy',
red: match.OverallStatus === 'down',
}"
>
{{ match.OverallStatus }}
</div>
</div>
<div v-else><p>No matching data</p></div>
</div>
</template>
<script>
export default {
components: {},
props: {
data: {
type: Array,
required: true,
},
SourceDatabaseName: {
type: String,
required: true,
},
},
data: function () {
return {};
},
methods: {},
computed: {
matchingData() {
return this.data.filter(
(a) => (a.SourceDatabaseName === this.SourceDatabaseName)
);
},
},
};
</script>
Error:-
matchingData:Cannot read properties of undefined (reading ‘filter’)
Vue Dev Tools screenshoot:-
As you can see in List.vue component, i have props which consists of data and sourcedatabasename….. Where i am able to get the sourcedatabasename but data is data:undefined.
and also minly in computed property, because data is undefined, filter also not working and throwing error as matchingData:Cannot read properties of undefined (reading ‘filter’)
Can you please help me out why it is getting as undefined?? Thanks.