From d11c0036b58fdf15bea7710f17c50ae893be5eb9 Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Mon, 14 Feb 2022 08:11:42 +0000 Subject: [PATCH] Do not use a store for API --- web/src/api.ts | 26 ++++++++++++++++++++++++++ web/src/components/Autocomplete.vue | 5 ++--- web/src/pages/Account.vue | 5 ++--- web/src/pages/Settings.vue | 8 +++----- web/src/stores/api.ts | 28 ---------------------------- web/src/stores/budget-account.ts | 8 +++----- web/src/stores/budget.ts | 11 ++++------- web/src/stores/session.ts | 8 +++----- 8 files changed, 43 insertions(+), 56 deletions(-) create mode 100644 web/src/api.ts delete mode 100644 web/src/stores/api.ts diff --git a/web/src/api.ts b/web/src/api.ts new file mode 100644 index 0000000..c245db5 --- /dev/null +++ b/web/src/api.ts @@ -0,0 +1,26 @@ +import { useSessionStore } from "./stores/session"; + +export const BASE_URL = "/api/v1" + +export function GET(path: string) { + const sessionStore = useSessionStore(); + return fetch(BASE_URL + path, { + headers: sessionStore.AuthHeaders, + }) +}; + +export function POST(path: string, body: FormData | string | null) { + const sessionStore = useSessionStore(); + return fetch(BASE_URL + path, { + method: "POST", + headers: sessionStore.AuthHeaders, + body: body, + }) +} +export function DELETE(path: string) { + const sessionStore = useSessionStore(); + return fetch(BASE_URL + path, { + method: "DELETE", + headers: sessionStore.AuthHeaders, + }) +} \ No newline at end of file diff --git a/web/src/components/Autocomplete.vue b/web/src/components/Autocomplete.vue index 535d661..22d6472 100644 --- a/web/src/components/Autocomplete.vue +++ b/web/src/components/Autocomplete.vue @@ -1,6 +1,6 @@