[Vuejs]-Vue Script Setup Appears To Be Causing Firebase And Vuex Store Issues

0👍

If you want to do async tasks inside the setup function you should do it in one of the lifecycle hooks and not on root level. It is possible on top level but experimental right now: https://vuejs.org/api/sfc-script-setup.html#top-level-await

So I recommend you to do something like this in your setup function:

import { onMounted } from 'vue';
...
onMounted(async () => {
   await store.dispatch('getEvents');
   const eventsImport = computed(() => store.getters.events);
   const events = [];
   eventsImport.value.forEach((event) => events.push(event));
   console.log(`Events Array: ${events}`);
});

Leave a comment