Loading data async function inside composite pina #2860
Replies: 1 comment
-
Add the await fetch in a async action function |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am loading data from an external source using a async fetch.
I want to save the data in the Pinia store.
Any time I add an await codium adds the async after zones
Then when I try to use it it is not found
I am lost on this one, I have searched for about a day for an answer.
*side note, I have written the fetch in rust and compiled it to WASM. It works in components
`
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
import { wasm, conf } from '@/main.ts'
export const useCFStore = defineStore('zones', async () => {
const hloaded = ref(false)
const zones = computed(() => raw_zones)
const opts: Array<[string, string]> = [['per_page', '50']]
const raw_zones: Map<string, wasm.MiniZone> = await wasm.get_zones(conf, '', opts, null)
return { hloaded, zones }
})
`
import { useCFStore } from '@/stores/cloudflare' const cf = useCFStore() console.log(cf.hloaded, cf.zones)
Beta Was this translation helpful? Give feedback.
All reactions