From 3640c0db11308481db1a1b1fb960efb6ec87f6d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Mon, 25 Sep 2023 19:23:37 -0400 Subject: [PATCH] feat(composables): add fetch helper function extend useFetch with a helper that prepends `/api` to the url, as well as makes the default http method "GET" --- composables/useApiFetch.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 composables/useApiFetch.ts diff --git a/composables/useApiFetch.ts b/composables/useApiFetch.ts new file mode 100644 index 0000000..c125c15 --- /dev/null +++ b/composables/useApiFetch.ts @@ -0,0 +1,11 @@ +import { UseFetchOptions } from "nuxt/app"; + +const useApiFetch = async (url: string, options?: any) => { + const at = useCookie("rockfic_cookie", {default: undefined}) + return useFetch("/api" + url, { + method: "get", + ...options, + }) +} + +export default useApiFetch \ No newline at end of file