[Vuejs]-Pinia getter does not filter state (options API)

-1👍

You can try like this:

import axios from 'axios';
import { defineStore } from 'pinia';

const useDetailsStore = defineStore('details', {
  getters: 
  {
     filteredDetails(state)
     {
       return (state.product?.details || []).map(product => ({
         ...product,
         values: product.values.filter(val => val.isOnline && val.isDisplayable),
       });
    },
});

export default useDetailsStore;

Leave a comment