import type { FetchOptions } from 'ofetch'; export const useApi = () => { const config = useRuntimeConfig(); const apiFetch = $fetch.create({ baseURL: config.public.apiBase, }); const get = (url: string, options?: FetchOptions) => apiFetch(url, { method: 'GET', ...options }); const post = >( url: string, body?: PayloadT, options?: FetchOptions, ) => apiFetch(url, { method: 'POST', body, ...options }); const put = >( url: string, body?: PayloadT, options?: FetchOptions, ) => apiFetch(url, { method: 'PUT', body, ...options }); const patch = >( url: string, body?: PayloadT, options?: FetchOptions, ) => apiFetch(url, { method: 'PATCH', body, ...options }); const del = (url: string, options?: FetchOptions) => apiFetch(url, { method: 'DELETE', ...options }); return { get, post, put, patch, del }; };