Skip to content

Commit

Permalink
refactor: rename to ApiClientFetcher
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Oct 25, 2023
1 parent d0ed4fe commit d64807d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ofetch } from 'ofetch'
import { joinURL } from 'ufo'
import type { FetchOptions } from 'ofetch'
import type { ApiClient, ApiMethodHandler, ResponseType } from './types'
import type { ApiClient, ApiClientFetcher, ResponseType } from './types'
import { mergeFetchOptions } from './utils'

const payloadMethods = ['POST', 'PUT', 'DELETE', 'PATCH']
Expand All @@ -23,7 +23,7 @@ export function createClient<R extends ResponseType = 'json'>(
if (!['GET', ...payloadMethods].includes(method))
return p(joinURL(url, key))

const handler: ApiMethodHandler = <T = any, R extends ResponseType = 'json'>(
const handler: ApiClientFetcher = <T = any, R extends ResponseType = 'json'>(
data?: any,
opts: FetchOptions<R> = {},
) => {
Expand Down
12 changes: 6 additions & 6 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type MappedType<
JsonType = any,
> = R extends keyof ResponseMap ? ResponseMap[R] : JsonType

export type ApiMethodHandler<Data = never> = <
export type ApiClientFetcher<Data = never> = <
T = any,
R extends ResponseType = 'json',
>(
Expand All @@ -24,9 +24,9 @@ export type ApiClient = {
[key: string]: ApiClient
(...args: (string | number)[]): ApiClient
} & {
get: ApiMethodHandler<FetchOptions['query']>
post: ApiMethodHandler<FetchOptions['body']>
put: ApiMethodHandler<FetchOptions['body']>
delete: ApiMethodHandler<FetchOptions['body']>
patch: ApiMethodHandler<FetchOptions['body']>
get: ApiClientFetcher<FetchOptions['query']>
post: ApiClientFetcher<FetchOptions['body']>
put: ApiClientFetcher<FetchOptions['body']>
delete: ApiClientFetcher<FetchOptions['body']>
patch: ApiClientFetcher<FetchOptions['body']>
}

0 comments on commit d64807d

Please sign in to comment.