Closed patarapolw closed 4 years ago
This can easily be solved with removing class properties, but it makes it impossible to set default value for asyncData.
@Component({ components: { PostQuery } }) export default class Search extends Vue { // defaults = { // posts: [], // count: 0 // }; async asyncData({ $axios, $payloadURL, route }: any) { if(process.static && process.client && $payloadURL) { return await $axios.$get($payloadURL(route)) } const ps = searchPosts({ isBlog: true, current: true, posts: await axiosOrImport(`/build/posts.json`, hash.posts._header) }); const posts = await Promise.all(ps.slice(0, config.posts.perPage).map(async (p) => { p.teaser = await teaserStore.get(p.path, p.h); return p; })); // this.defaults return defined return { defaults: { posts, count: ps.length } }; } }
It was a bug on my end, the upper code does work.
This can easily be solved with removing class properties, but it makes it impossible to set default value for asyncData.