I have these two routes /services
and /services/parents
and each page is stored in a vue
file like this:
// File location : "/pages/services/index.vue"
<tr v-for="service in services" :key="service.id">
<td class="check-col"><input type="checkbox"></td>
<td class="number-col">{{ service.id }}</td>
<td>{{ service.name }}</td>
<td>{{ service.slug }}</td>
<td>
<template v-if="service.children.length">
<template v-for="(child, index) in service.children">
<nuxt-link :to="'/admin/services/' + child.id" :key="child.id">
{{ child.name }}
</nuxt-link>
<span :key="child.id" v-if="(index+1) < service.children.length">, </span>
</template>
</template>
<span v-else>--</span>
</td>
</tr>
and in my /services/parents
page, i have:
// File location : "/pages/services/parents.vue"
<tr v-for="service in services" :key="service.id">
<td>{{ service.id }}</td>
<td>{{ service.name }}</td>
</tr>
<script>
export default{
computed: {
services() {
return this.$store.getters['content-lists/services/list']
}
},
async fetch({ store, query }) {
let page = Number(query.page) || 1
let perPage = Number(store.getters['content-lists/services/perPage'])
let offset = (page - 1) * perPage
const max = await strapi.request('get', '/services/count')
store.commit('content-lists/services/setMaxPages', max)
store.commit('content-lists/services/empty')
const response = await strapi.request('post', '/graphql', {
data: {
query: `query {
services(limit: ${perPage}, start: ${offset}) {
id
name
slug
children {
id
name
}
}
}`
}
})
response.data.services.forEach((service) => {
store.commit('content-lists/services/add', {
id: service.id || service._id,
...service
})
})
}
}
</script>
When i navigate to parents page it gives me this error:
service.children is undefined
An error occurred while rendering the page. Check developer tools console for details.
It only happens when navigating with <nuxt-link>
if you type the url in browser address it works just fine.
I also checked console but there is no traces it just says : Type error: service.children is not defined
I appreciate any help in advance