title: How to correctly handle information fetch from an API with Pinia in Vue.js 3?
body: <p>I'm currently working on a project where to fetch data from an API.
  I need access to that data all over my app, so I thought that the best option was to use Pinia (usually I used Vuex, but I want to try this &quot;new&quot; store solution).</p>
  <p>My &quot;problem&quot; is that I really don't know if the way I achieve my goal is the best way or even a &quot;good practice&quot;. In my Pinia store I wrote this:</p>
  <pre><code>
  export const listadoADPs = defineStore(&quot;listado&quot;, {
    state: () =&gt; ({
      adps: [],
    }),
    actions: {
      getADPs() {
        const api =
          &quot;URL&quot;;
  
        fetch(api)
          .then((response) =&gt; response.json())
          .then(({ data }) =&gt; (this.adps = data))
          .catch((error) =&gt; console.log(error));
      },
    },
  });
  </code></pre>
  <p>Then, in my component I coded this:</p>
  <pre><code>&lt;script setup&gt;
  import { ref, computed } from &quot;vue&quot;;
  import { listadoADPs } from &quot;@/stores/adps&quot;;
  const store = listadoADPs();
  
  const cards = ref([
    {
      number: computed(() =&gt; store.adps.length),
      description: &quot;ADPs vigentes&quot;,
    },
    {
      number: computed(
        () =&gt; store.adps.filter((adp) =&gt; adp.estado_cd === &quot;Suscrito&quot;).length
      ),
      description: &quot;Convenios de Desempeño Suscritos&quot;,
    },
    {
      number: 0,
      description: &quot;Alertas enviadas&quot;,
    },
  ]);
  &lt;/script&gt;
  </code></pre>
  <p>Specifically, I don't know if making a computed property for each &quot;number&quot; key in my array &quot;cards&quot; is right, I mean, finally is the same data, so why I can't make just one computed property and save the data in a variable?
  The thing is that if I work in that way when I reloaded the page, the data just disappears.</p>
  <p>Reading the documentation and much more, I think there is a reactivity issue that I still don't understand at all, but I really want to make well this code, so I prefer to ask to you.</p>