Skip to content

[FR] - Pass a promise to new props function #1126

Closed
@nirazul

Description

@nirazul

I really like the new possibility to pass props to route components, thanks for implementing it!

As this would be a nice opportunity to use a props method as an API data fetcher, I'm intersted in passing a Promise either directly or returning one by this function.

I imagine something like this:

function asnycProps(route) {
  return new Promise((resolve, reject) => {
    ApiFramework.fetch(/* some route config */)
      .then((data) => {
        resolve(data);
      });
  });
}

const router = new VueRouter({
  mode: 'history',
  base: __dirname,
  routes: [
    { path: '/dynamic', component: Hello, props: asyncProps }
  ]
})

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions