This repository was archived by the owner on Dec 5, 2024. It is now read-only.
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
help: Before mount, await useFetch #741
Open
Description
📚 What are you trying to do? Please describe.
On the client, before component will be mounted, I want to completely load data.
🔍 What have you tried?
setup() {
const pageData = ref<PageData | null>(null);
const {params, error} = useContext();
useFetch(async () => {
const pageDataStore = usePageDataStore();
await pageDataStore.fetchDataById(params.value.id);
pageData.value = pageDataStore.currentData;
if (null === pageData.value) {
return error({statusCode: 404, message: 'Not Found'});
}
});
return {
pageData,
};
},
ℹ️ Additional context
According to Nuxt lifecycle, I expect that useFetch
will be completely done, like fetch
does.
This is especially distressing in pageComponents
- page transition is complete, but page is empty and waiting for data.