Relative Content

Tag Archive for typescriptvue.jspinia

How to correctly implement typing for a generic pinia store in a composable?

Context VueJs 3.4.19 Typescript 5.3.3 Pinia 2.1.6 In many views of my application, I need to fetch data from an API call. So each view have an onMounted() hook wich looks like: // Users.vue import { useUserStore } from ‘@/store/userStore’; const userStore = useUserStore(); onMounted(async() => { try { await userStore.fetchUsers(); } catch (err) { […]