[Vuejs]-How do I pass a parameter to pinia getter in vue?

0👍

For anyone who might have something similar in the future. You can pass in a value to a getter like so

    ...mapState(useThreadsStore, {
      thread(store) {
        return store.thread(this.id);
      },
    }),

0👍

export const useStore = defineStore('main', {
  getters: {
    getUserById: (state) => {
      return (userId) => state.users.find((user) => user.id === userId)
    },
  },
})```

[official docs][1]


  [1]: https://pinia.vuejs.org/core-concepts/getters.html#Passing-arguments-to-getters

Leave a comment