refactor(composables): make useApiFetch typing stronger(?)

This commit is contained in:
parent 3a1ddf55e4
commit bb1f410d88
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

@ -1,5 +1,5 @@
import { StorageSerializers } from "@vueuse/core"; import { AsyncData, UseFetchOptions } from "#app";
import { UseFetchOptions } from "nuxt/app"; import { NitroFetchRequest } from "nitropack";
const useApiFetch = async <T>(url: string, options?: any) => { const useApiFetch = async <T>(url: string, options?: any) => {
// const { token } = useAuth(); // const { token } = useAuth();
@ -32,13 +32,13 @@ const useApiFetch = async <T>(url: string, options?: any) => {
// } else { // } else {
// console.log(`Getting value from cache for ${url}`); // console.log(`Getting value from cache for ${url}`);
// } // }
const data = await useFetch<T>("/api" + url, { console.log(`API => /api${url}`);
return (await useFetch<T>(`/api${url}`, {
// @ts-ignore
method: "get", method: "get",
headers: head, headers: head,
...options, ...options,
}); })) as AsyncData<T, any>;
return data;
}; };
export default useApiFetch; export default useApiFetch;