From 3e55e82fb7d3f49f5f087010916b6a26f9bf6c22 Mon Sep 17 00:00:00 2001 From: clonbg Date: Mon, 11 Aug 2025 19:04:24 +0200 Subject: [PATCH] Replace Chuck Norris API with lists endpoint The commit replaces the Chuck Norris joke functionality with a new lists feature that fetches data from a local API endpoint using auth tokens. --- app/pages/index.vue | 28 ++++------------------------ app/stores/chuck.js | 14 -------------- app/stores/listas.js | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+), 38 deletions(-) delete mode 100644 app/stores/chuck.js create mode 100644 app/stores/listas.js diff --git a/app/pages/index.vue b/app/pages/index.vue index c9012ff..7d39d98 100644 --- a/app/pages/index.vue +++ b/app/pages/index.vue @@ -2,23 +2,9 @@ - chuck norris
My Application's Home Page
- {{ norrisStore.response }} - {{ data }} - {{ status }} - {{ refreshToken }} -
-
- Refresca token -
-
- Logout + {{ listasStore.listas }}
@@ -28,18 +14,12 @@ definePageMeta({ auth: true, }); import { ref, onMounted } from "vue"; -import { useChuckStore } from "~/stores/chuck"; import { useSystemStore } from "~/stores/system"; +import { useListasStore } from "~/stores/listas"; +const listasStore = useListasStore(); const systemStore = useSystemStore(); -const norrisStore = useChuckStore(); -const { data, status, refresh, refreshToken, signOut } = useAuth(); - -const logout = async () => { - await systemStore.deleteCookies(); - await signOut({ callbackUrl: "/login" }); -}; onMounted(async () => { - await norrisStore.getData(); + await listasStore.getData(); }); diff --git a/app/stores/chuck.js b/app/stores/chuck.js deleted file mode 100644 index a06e504..0000000 --- a/app/stores/chuck.js +++ /dev/null @@ -1,14 +0,0 @@ -import { defineStore } from "pinia"; - -export const useChuckStore = defineStore("chuckNorris", { - state: () => ({ - response: "", - }), - actions: { - async getData() { - const response = await fetch("https://api.chucknorris.io/jokes/random"); - const data = await response.json(); - this.response = data; - }, - }, -}); diff --git a/app/stores/listas.js b/app/stores/listas.js new file mode 100644 index 0000000..5f63377 --- /dev/null +++ b/app/stores/listas.js @@ -0,0 +1,20 @@ +import { defineStore } from "pinia"; +const { token } = useAuth(); + +export const useListasStore = defineStore("listas", { + state: () => ({ + listas: [], + }), + actions: { + async getData() { + const response = await fetch("http://127.0.0.1:8000/lista/", { + method: "GET", + headers: { + Authorization: `${token.value}`, + }, + }); + const data = await response.json(); + this.listas = data; + }, + }, +});