{{ count }} albums loaded
+{{ msg }} {{ status }}
diff --git a/src/main.ts b/src/main.ts index 6bc1df8..4ecb7a6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,8 @@ +import { createPinia } from "pinia"; import { createApp } from "vue"; import App from "@/App.vue"; import "@/assets/styles/global.css"; -createApp(App).mount("#app"); +const app = createApp(App); +app.use(createPinia()); +app.mount("#app"); diff --git a/src/stores/albums.ts b/src/stores/albums.ts new file mode 100644 index 0000000..851e7c6 --- /dev/null +++ b/src/stores/albums.ts @@ -0,0 +1,57 @@ +// src/stores/albums.ts +import { ref, computed } from "vue"; +import { defineStore } from "pinia"; +import axios from "axios"; +import type { Album } from "@/types/album"; + +const API_URL = "https://jsonplaceholder.typicode.com/albums"; + +export const useAlbumsStore = defineStore("albums", () => { + // ---- state ---- + const albums = ref