Hi.
I have such setup.
First I thought everything fine
But then I notice that Nuxt generates routes for any value and doesn't return Error
This endpoint moooooney
doesn't exist of course. And If I go to this route I got an error like it should:
How to setup everything, so Nuxt understand, that to show only the data that exist?
This is my articles/_section/index.vue
file
asyncData ({ req, params, error }) {
return axios.get(`${process.env.baseUrl}/api/articles/${params.section}`)
.then((res) => {
return { articles: res.data }
})
.catch(() => {
error({ statusCode: 404, message: 'Section not found' })
})
}
This is my articles/_section/_slug.vue
file
asyncData ({ req, params, error }) {
return axios.get(`${process.env.baseUrl}/api/articles/${params.section}/${params.slug}`)
.then((res) => {
return { article: res.data }
})
.catch(() => {
error({ statusCode: 404, message: 'Pooooost not found' })
})
}
I have only 5 sections in my API data.
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1520">#c1520</a>)</em></sub></div>