Last active
April 6, 2023 16:44
-
-
Save NandoKstroNet/13eb60d4767653b79387c84820adef96 to your computer and use it in GitHub Desktop.
Store Pinia Products - Curso Laravel Mastery Bloco 3 - https://codeexperts.com.br
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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