[Vuejs]-Async mounted hook is not awaiting Feathers-Vuex useFind

0👍

To use useFind you need to use vue composable api instead of normal functions/options.

Here’s how it should looks like instead:

export default {
  component: 'PageName',
  setup(_ , { root }) {
    const { Book } = root.$FeathersVuex.api;
    const pathBody = root.$route.path.split("/")[1];

    const bookParams = computed(() => {
      return {
        query: {
          referral_link: pathBody
        }
      };
    });

    const { items: books } = await useFind({
      model: Book,
      params: bookParams
    });

    return {
      books
    }
  }
}

Also the data on won’t be there on mounted since it took time to actually fetch. You can add isPending besides the returned items. Then use it on your template with v-if.

Leave a comment