Deal With It
Deal With It

Reputation: 43

Vue.js 3 and Pinia store filled in async by API

I'm creating an application in Vue.js 3 + Pinia. I created an action that call - async function with await on axios call - an API to fill the whole store for a page, but don't work.

Are there any method to await the full update of the store? The issue at the moment is that getters return nothing when loading the page. I'm also following the official documentation for deconstruct the getters and I launch the action call in "wrapped" in "onBeforeMount".

More detail about the what is the workflow:

In the main page I call the API to fetch in the store all the data (also the data for the Vue-Components), the function is wrapped with "onBeforeMount". The data that is not related to a Vue-Component is printed to the main page.

In the component I call the storage (useStore()) and I use "storeToRefs" to deconstruct the getter and the result is undefined.

A possible solution: This issue occurred because I want to avoid to use props to Vue-Components also because I have nested components sometimes.

Upvotes: 0

Views: 913

Answers (0)

Related Questions