UNPKG

nuxt3-api-gen

Version:

This tool generates TypeScript types and API methods based on a Swagger/OpenAPI schema.

17 lines (16 loc) 435 B
interface TE { statusCode: number message: string } export default function useApi<T>(url: string, options = {}) { const config = useRuntimeConfig() return useFetch<T, TE>(url, { baseURL: config.public.apiBase, watch: false, immediate: !['POST', 'PUT', 'PATCH', 'DELETE'].includes(options?.method), // headers: { // 'Authorization': `Bearer {access_token}` // }, ...options }) }