Hello!
I’m using Async Route to fetch data before and pass it as props.
{
path: "/ore/projects/:projectId/",
name: "project-detail",
async: (to, from, resolve, reject) => {
const { projectId } = to.params;
// fetch data from backend
api.findTasksByProjectId(projectId).then(result => {
const { tasks } = result.data;
// Async Lazy Components
const ProjectDetail = () => import("../pages/ProjectDetail.vue");
return ProjectDetail().then(c => {
resolve({ component: c.default }, { props: { tasks } });
});
});
}
},
I’ve got doubts that this is not a good strategy becouse I’ve a wait moment in loading the page that give a bed feel to the user.
I didn’t find examples of Async Route that use async function (Promises) to pass data as props.
Is it the right way to use async route?
Thank you for your help.
PS: is Async Lazy Components implemented in the right approach? I’ve also some doubts about it
Ref: