From 115bc7371f02921f2b3827ddf0def2ff60a15b57 Mon Sep 17 00:00:00 2001 From: Sainul Abid Date: Wed, 3 Jul 2024 15:19:42 +0530 Subject: [PATCH] patch: add types for --- package.json | 2 +- src/index.ts | 6 +++--- src/types.ts | 7 ++++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index cbf66bb..bdf3cd3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "useipa", - "version": "0.3.4", + "version": "0.3.5", "description": "A react hook for api fetching", "main": "./dist/index.js", "module": "./dist/index.mjs", diff --git a/src/index.ts b/src/index.ts index 047d090..34bc154 100644 --- a/src/index.ts +++ b/src/index.ts @@ -131,16 +131,16 @@ export const useFormApi: UseForm = (instance): UseFormResponse => { * @param {string} endpoint * @param {string} [method=GET] * @param {RequestConfig} [config] - * @returns {Promise} + * @returns {Promise} */ -export const asyncApi: AsyncApi = async ( +export const asyncApi: AsyncApi = async ( endpoint: string, method = 'GET', config?: RequestConfig ) => { const apiClient = api - const { data } = await apiClient({ ...config, url: endpoint, method }) + const { data } = await apiClient({ ...config, url: endpoint, method }) return data } diff --git a/src/types.ts b/src/types.ts index f3a4c12..83c8e74 100644 --- a/src/types.ts +++ b/src/types.ts @@ -39,5 +39,10 @@ export type UseApiSubmit = { (endpoint: string, config: RequestConfig): void } -export type AsyncApi = (endpoint: string, method?: Method, config?: RequestConfig) => Promise +export type AsyncApi = ( + endpoint: string, + method?: Method, + config?: RequestConfig +) => Promise + export type UseApi = (instance?: CreateAxiosDefaults) => UseApiResponse