Skip to content

Instantly share code, notes, and snippets.

@NandoKstroNet
Last active April 6, 2023 16:44
Show Gist options
  • Save NandoKstroNet/13eb60d4767653b79387c84820adef96 to your computer and use it in GitHub Desktop.
Save NandoKstroNet/13eb60d4767653b79387c84820adef96 to your computer and use it in GitHub Desktop.
Store Pinia Products - Curso Laravel Mastery Bloco 3 - https://codeexperts.com.br
import { defineStore } from "pinia";
import httpClient from "@/services/http-client";
export const useProducts = defineStore("products", {
state: () => ({ products: null }),
getters: {
getProducts(state) {
return state.products;
},
},
actions: {
getAllProducts() {
httpClient.get('/products').then((response) => (this.products = response.data));
},
},
persist: true,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment