I'm having problems dealing with async data in Nuxt dynamic routes.
Example of folder structure,
My async data
async asyncData({context, error, req}) {
try {
const api = await Prismic.getApi(PrismicConfig.apiEndpoint, {req})
let document = []
const result = await api.getByUID('news', this.$route.params.slug)
document = result.results
return {
document,
documentId: result.id,
}
} catch (e) {
error({ statusCode: 404, message: 'Page not found' })
}
},
So I always end up in 404 page not found. I tried with other examples of async data that works ok on normal "non dynamic routes" an it also returns 404.
I'm assuming that this is problem related with Async data Nuxt has with components as well and that this is something Nuxt will handle in version 3.0?
But until then I would appreciate if you could help me out with this, I need to make this work somehow.
I'm using Prismic as headless API cms.