Composition-api: How can I use asynchronous methods in setup()

Created on 14 Feb 2020  路  2Comments  路  Source: vuejs/composition-api

<script lang="ts">
import { createComponent } from "@vue/composition-api";

import { SplashPage } from "../../lib/vue-viewmodels";

export default createComponent({
  async setup(props, context) {
    await SplashPage.init(2000, context.root.$router, "plan", "login");
  }
});
</script>

ERROR: "setup" must return a "Object" or a "Function", got "Promise"

Most helpful comment

the async setup requires using Suspense which doesn't exist in Vue 2. The async setup is only available in Vue 3

All 2 comments

the async setup requires using Suspense which doesn't exist in Vue 2. The async setup is only available in Vue 3

Thanks for your reply.

Was this page helpful?
0 / 5 - 0 ratings