refactor(composables): make useApiFetch
typing stronger(?)
This commit is contained in:
parent
3a1ddf55e4
commit
bb1f410d88
@ -1,5 +1,5 @@
|
||||
import { StorageSerializers } from "@vueuse/core";
|
||||
import { UseFetchOptions } from "nuxt/app";
|
||||
import { AsyncData, UseFetchOptions } from "#app";
|
||||
import { NitroFetchRequest } from "nitropack";
|
||||
|
||||
const useApiFetch = async <T>(url: string, options?: any) => {
|
||||
// const { token } = useAuth();
|
||||
@ -32,13 +32,13 @@ const useApiFetch = async <T>(url: string, options?: any) => {
|
||||
// } else {
|
||||
// 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",
|
||||
headers: head,
|
||||
...options,
|
||||
});
|
||||
|
||||
return data;
|
||||
})) as AsyncData<T, any>;
|
||||
};
|
||||
|
||||
export default useApiFetch;
|
||||
|
Loading…
Reference in New Issue
Block a user