react-api-kit 1.0.3 β†’ 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,133 +1,382 @@
1
- # πŸš€ API Client (Axios + TanStack Query)
1
+ # πŸš€ react-api-kit
2
2
 
3
- A lightweight, opinion-free API client built on **Axios** and **TanStack Query**, designed for modern React applications.
3
+ A lightweight, production-ready API client built on **Axios** + **TanStack Query** for React applications.
4
4
 
5
- βœ” No UI dependencies
6
- βœ” Global success & error hooks
7
- βœ” Works with any toast library
8
- βœ” React Query–ready
9
- βœ” Production-grade architecture
5
+ [![npm version](https://img.shields.io/npm/v/react-api-kit)](https://www.npmjs.com/package/react-api-kit)
6
+ [![license](https://img.shields.io/npm/l/react-api-kit)](./LICENSE)
7
+
8
+ βœ” Auto Bearer / Token / Custom auth headers
9
+ βœ” Custom static headers per project
10
+ βœ” Global error handling with toast support
11
+ βœ” Auto logout on 401
12
+ βœ” React Query–ready hooks (GET, POST, PATCH, DELETE)
13
+ βœ” No UI dependencies β€” works with any toast library
10
14
 
11
15
  ---
12
16
 
13
17
  ## πŸ“¦ Installation
14
18
 
15
19
  ```bash
16
- npm install axios @tanstack/react-query
20
+ npm install react-api-kit axios @tanstack/react-query
17
21
  ```
18
22
 
19
- > **Peer requirements**
23
+ > **Peer Dependencies:** React β‰₯ 17, Axios β‰₯ 1, TanStack Query β‰₯ 4
20
24
 
21
- - React 18+
22
- - TanStack Query v5+
25
+ ---
23
26
 
24
- ## πŸ”§ Quick Start
27
+ ## ⚑ Quick Start
25
28
 
26
- ### 1️⃣ Setup React Query Provider
29
+ ### 1. Wrap your app with React Query Provider
27
30
 
28
31
  ```tsx
32
+ // main.tsx
29
33
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
30
34
 
31
35
  const queryClient = new QueryClient();
32
36
 
33
- export function AppProviders({ children }) {
37
+ export default function App() {
34
38
  return (
35
- <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
39
+ <QueryClientProvider client={queryClient}>
40
+ <YourApp />
41
+ </QueryClientProvider>
36
42
  );
37
43
  }
38
44
  ```
39
45
 
40
- ---
41
-
42
- ### 2️⃣ Configure the API (Required)
43
-
44
- Call `setupApi` **once**, ideally at application startup.
46
+ ### 2. Configure the API (once at app startup)
45
47
 
46
48
  ```ts
49
+ // api.config.ts
47
50
  import { setupApi } from "react-api-kit";
48
- import { toast } from "react-toastify";
49
51
 
50
52
  setupApi({
51
- baseURL: "/api",
52
-
53
+ baseURL: "https://api.example.com",
54
+ tokenType: "Bearer",
53
55
  getToken: () => localStorage.getItem("token"),
56
+ });
57
+ ```
54
58
 
59
+ Then import `api.config.ts` in your `main.tsx` before anything else.
60
+
61
+ ---
62
+
63
+ ## πŸ”§ `setupApi` β€” Full Configuration
64
+
65
+ ```ts
66
+ setupApi({
67
+ // ─── Required ───────────────────────────────
68
+ baseURL: "https://api.example.com",
69
+
70
+ // ─── Auth Token ─────────────────────────────
71
+ tokenType: "Bearer", // "Bearer" | "Token" | "JWT" | "ApiKey" | any string
72
+ getToken: () => localStorage.getItem("token"), // return null to skip Authorization header
73
+
74
+ // ─── Custom Static Headers ──────────────────
75
+ headers: {
76
+ "X-Api-Key": "your-api-key", // sent with every request
77
+ "Accept-Language": "en",
78
+ "X-App-Version": "1.0.0",
79
+ },
80
+
81
+ // ─── Toast Notifications ────────────────────
55
82
  toast: {
56
83
  success: (msg) => toast.success(msg),
57
- error: (msg) => toast.error(msg),
84
+ error: (msg) => toast.error(msg),
85
+ info: (msg) => toast.info(msg), // optional
86
+ warn: (msg) => toast.warn(msg), // optional
87
+ },
88
+ toastOptions: {
89
+ autoClose: 3000,
90
+ position: "top-right",
91
+ theme: "light", // "light" | "dark" | "colored"
58
92
  },
59
93
 
94
+ // ─── Custom Error Messages ───────────────────
60
95
  errorMessages: {
61
- 401: "Session expired",
62
- 403: "Access denied",
63
- 500: "Server error",
96
+ 401: "Session expired. Please login again.",
97
+ 403: "Access denied.",
98
+ 404: "Not found.",
99
+ 500: "Server error. Try again later.",
64
100
  },
65
101
 
66
- onSuccess: (data) => {
67
- console.log("Global success:", data);
102
+ // ─── Global Callbacks ───────────────────────
103
+ onSuccess: (data) => console.log("Success:", data),
104
+ onError: (error, message) => console.error("Error:", message),
105
+ onLogout: () => {
106
+ localStorage.clear();
107
+ window.location.href = "/login"; // auto-called on 401
68
108
  },
109
+ });
110
+ ```
111
+
112
+ ---
113
+
114
+ ## πŸ”‘ Auth Header β€” `tokenType` Examples
115
+
116
+ | `tokenType` | `getToken()` returns | Header sent |
117
+ |-------------|----------------------|-------------|
118
+ | `"Bearer"` *(default)* | `"abc123"` | `Authorization: Bearer abc123` |
119
+ | `"Token"` | `"abc123"` | `Authorization: Token abc123` |
120
+ | `"JWT"` | `"abc123"` | `Authorization: JWT abc123` |
121
+ | `"ApiKey"` | `"abc123"` | `Authorization: ApiKey abc123` |
122
+ | `""` *(empty)* | `"abc123"` | `Authorization: abc123` |
123
+ | *(not set)* | `"abc123"` | `Authorization: Bearer abc123` |
124
+ | `"Bearer"` | `null` / not set | *(no Authorization header)* |
125
+
126
+ ---
127
+
128
+ ## πŸ“‹ Custom Headers β€” `headers` Examples
129
+
130
+ Use `headers` for static values that never change (API keys, app identifiers, language, etc.):
131
+
132
+ ```ts
133
+ // Single custom header
134
+ setupApi({
135
+ baseURL: "https://api.example.com",
136
+ headers: { "token_abc": "askfjshdfjk" },
137
+ });
138
+ // β†’ Every request: token_abc: askfjshdfjk
69
139
 
70
- onError: (error, message) => {
71
- console.error("Global error:", message, error);
140
+ // Multiple custom headers
141
+ setupApi({
142
+ baseURL: "https://api.example.com",
143
+ headers: {
144
+ "X-Api-Key": "your-api-key",
145
+ "X-App-ID": "my-app-001",
146
+ "Accept-Language": "en",
72
147
  },
148
+ });
73
149
 
74
- onLogout: () => {
75
- localStorage.clear();
76
- window.location.href = "/login";
150
+ // Custom header + Bearer token together
151
+ setupApi({
152
+ baseURL: "https://api.example.com",
153
+ tokenType: "Bearer",
154
+ getToken: () => localStorage.getItem("token"),
155
+ headers: {
156
+ "X-Api-Key": "your-api-key", // static
77
157
  },
78
158
  });
159
+ // Both headers sent on every request
79
160
  ```
80
161
 
81
162
  ---
82
163
 
83
- ## πŸ”” Toast Integration (Optional)
164
+ ## πŸͺ Hooks
84
165
 
85
- This package **does not ship a toast library**.
166
+ ### `useApiQuery` β€” Fetch data (GET)
86
167
 
87
- You pass your own implementation.
168
+ ```ts
169
+ const { data, isLoading, isError, refetch } = useApiQuery(
170
+ queryKey, // unique cache key array
171
+ method, // "GET" only for queries
172
+ endpoint, // API path
173
+ params?, // query string params (optional)
174
+ options? // TanStack Query options (optional)
175
+ );
176
+ ```
177
+
178
+ **Examples:**
179
+
180
+ ```tsx
181
+ // Basic GET
182
+ const { data, isLoading } = useApiQuery(["users"], "GET", "/users");
183
+
184
+ // GET with query params β†’ /users?page=1&limit=10
185
+ const { data } = useApiQuery(["users", 1], "GET", "/users", { page: 1, limit: 10 });
186
+
187
+ // GET with TanStack options
188
+ const { data } = useApiQuery(["user", id], "GET", `/users/${id}`, undefined, {
189
+ enabled: !!id, // only fetch when id exists
190
+ staleTime: 1000 * 60, // cache for 1 minute
191
+ retry: 2, // retry twice on failure
192
+ });
193
+
194
+ // Usage in component
195
+ function UserList() {
196
+ const { data, isLoading, isError } = useApiQuery(["users"], "GET", "/users");
197
+
198
+ if (isLoading) return <p>Loading...</p>;
199
+ if (isError) return <p>Error!</p>;
200
+ return <ul>{data?.map(u => <li key={u.id}>{u.name}</li>)}</ul>;
201
+ }
202
+ ```
88
203
 
89
204
  ---
90
205
 
91
- ## πŸͺ Hooks
206
+ ### `useApiMutation` β€” Create / Update / Delete
92
207
 
93
- ### `api`
208
+ ```ts
209
+ const { mutate, mutateAsync, isPending, isError } = useApiMutation(
210
+ mutationKey, // unique key array
211
+ method, // "POST" | "PATCH" | "DELETE" | "GET"
212
+ invalidateKey? // query keys to refetch after success (optional)
213
+ );
214
+ ```
215
+
216
+ Call `mutate` with `{ endpoint, data }`:
94
217
 
95
218
  ```ts
96
- import { api } from "react-api-kit";
219
+ mutate({ endpoint: "/endpoint", data: { ...payload } });
220
+ ```
97
221
 
98
- const fetchUsers = () => api.get("/users").then((res) => res.data);
222
+ **Examples:**
223
+
224
+ #### POST β€” Create
225
+
226
+ ```tsx
227
+ const { mutate, isPending } = useApiMutation(
228
+ ["createUser"],
229
+ "POST",
230
+ ["users"] // refetches ["users"] query on success
231
+ );
232
+
233
+ const handleCreate = () => {
234
+ mutate({
235
+ endpoint: "/users",
236
+ data: { name: "John", email: "john@example.com" },
237
+ });
238
+ };
99
239
  ```
100
240
 
101
- ### useApiQuery get
241
+ #### PATCH β€” Update
102
242
 
103
- const { data, isLoading } = useApiQuery(
104
- ["users"],"GET","/ENDPOINT/,{parems:value},{ ...options} );
243
+ ```tsx
244
+ const { mutate } = useApiMutation(["updateUser"], "PATCH", ["users"]);
105
245
 
106
- ### `useApiMutation`
246
+ mutate({
247
+ endpoint: `/users/${id}`,
248
+ data: { name: "Updated Name" },
249
+ });
250
+ ```
107
251
 
108
- ```ts
109
- import { useApiMutation, api } from "react-api-kit";
252
+ #### DELETE β€” Remove
110
253
 
111
- // POST Req
112
- const { mutate, isPending } = useApiMutation(["POST KEY"], "POST", "/users", [
113
- "Validate",
114
- ]);
254
+ ```tsx
255
+ const { mutate } = useApiMutation(["deleteUser"], "DELETE", ["users"]);
115
256
 
116
- // GET Req
117
- const { mutate, isPending } = useApiMutation(["GET KEY"], "GET", "/users", [
118
- "Validate",
119
- ]);
257
+ mutate({ endpoint: `/users/${id}` });
258
+ ```
120
259
 
121
- // PATCH Req
122
- const { mutate, isPending } = useApiMutation(["PATCH KEY"], "PATCH", "/users", [
123
- "Validate",
124
- ]);
260
+ #### With callbacks
125
261
 
126
- //Delete Feq
127
- const { mutate, isPending } = useApiMutation(
128
- ["DELETE KEY"],
129
- "DELETE",
130
- "/users",
131
- ["Validate"]
262
+ ```tsx
263
+ const { mutate } = useApiMutation(["createUser"], "POST", ["users"]);
264
+
265
+ mutate(
266
+ { endpoint: "/users", data: { name: "John" } },
267
+ {
268
+ onSuccess: (data) => toast.success("User created!"),
269
+ onError: (err) => toast.error("Failed to create user"),
270
+ }
132
271
  );
133
272
  ```
273
+
274
+ #### Using `mutateAsync` (await)
275
+
276
+ ```tsx
277
+ const { mutateAsync, isPending } = useApiMutation(["createUser"], "POST");
278
+
279
+ const handleSubmit = async (formData) => {
280
+ try {
281
+ const result = await mutateAsync({ endpoint: "/users", data: formData });
282
+ console.log("Created:", result);
283
+ } catch (err) {
284
+ console.error(err);
285
+ }
286
+ };
287
+ ```
288
+
289
+ ---
290
+
291
+ ### `api` β€” Direct Axios Instance
292
+
293
+ For cases where you need full control:
294
+
295
+ ```ts
296
+ import { api } from "react-api-kit";
297
+
298
+ // GET
299
+ const users = await api.get("/users").then(res => res.data);
300
+
301
+ // GET with params
302
+ const res = await api.get("/orders", { params: { status: "pending" } });
303
+
304
+ // POST
305
+ const res = await api.post("/users", { name: "John" });
306
+
307
+ // PATCH
308
+ const res = await api.patch(`/users/${id}`, { name: "Updated" });
309
+
310
+ // DELETE
311
+ const res = await api.delete(`/users/${id}`);
312
+
313
+ // Custom header for a single request only
314
+ const res = await api.get("/report", {
315
+ headers: { "X-Export-Format": "pdf" },
316
+ });
317
+ ```
318
+
319
+ > All requests made via `api` also get the global auth header and custom headers automatically.
320
+
321
+ ---
322
+
323
+ ## ⚠️ Error Handling
324
+
325
+ Errors are handled automatically via the response interceptor with a **4-level priority**:
326
+
327
+ | Priority | Source |
328
+ |----------|--------|
329
+ | 1️⃣ | `error.response.data.message` from backend |
330
+ | 2️⃣ | Your custom `errorMessages[status]` in `setupApi` |
331
+ | 3️⃣ | Built-in default messages (see table below) |
332
+ | 4️⃣ | Fallback: `error.message` or `"Network Error"` |
333
+
334
+ **Built-in default status messages:**
335
+
336
+ | Status | Default Message |
337
+ |--------|----------------|
338
+ | `400` | Bad request. Please check your input. |
339
+ | `401` | Session expired. Please login again. *(+ auto logout)* |
340
+ | `403` | You do not have permission to perform this action. |
341
+ | `404` | Requested resource not found. |
342
+ | `409` | Conflict occurred. Please try again. |
343
+ | `422` | Validation error. Please check the form. |
344
+ | `500` | Server error. Please try again later. |
345
+
346
+ > **401 Auto Logout:** When a `401` response is received, `onLogout()` is called automatically.
347
+
348
+ ---
349
+
350
+ ## πŸ“ Package Structure
351
+
352
+ ```
353
+ src/
354
+ β”œβ”€β”€ config.ts β†’ ApiConfig interface + setupApi()
355
+ β”œβ”€β”€ index.ts β†’ Public exports
356
+ β”œβ”€β”€ api/
357
+ β”‚ β”œβ”€β”€ axios.ts β†’ Axios instance + request interceptor (auth + headers)
358
+ β”‚ β”œβ”€β”€ interceptors.ts β†’ Response interceptor (error handling + auto logout)
359
+ β”‚ └── globalApi.ts β†’ GET / POST / PATCH / DELETE wrappers
360
+ └── hooks/
361
+ β”œβ”€β”€ useApiQuery.ts β†’ useQuery wrapper
362
+ └── useApiMutation.ts β†’ useMutation wrapper
363
+ ```
364
+
365
+ ---
366
+
367
+ ## πŸ”— Exports
368
+
369
+ ```ts
370
+ import {
371
+ setupApi, // configure baseURL, token, headers, toast, etc.
372
+ api, // raw Axios instance (with interceptors)
373
+ useApiQuery, // TanStack Query hook for GET
374
+ useApiMutation, // TanStack Query hook for POST / PATCH / DELETE
375
+ } from "react-api-kit";
376
+ ```
377
+
378
+ ---
379
+
380
+ ## πŸ“„ License
381
+
382
+ ISC Β© [Ajay Kammar](https://github.com/)
@@ -1,16 +1,22 @@
1
1
  import c from "axios";
2
- import { useQuery as p, useQueryClient as d, useMutation as l } from "@tanstack/react-query";
3
- let o;
4
- const h = (e) => {
5
- o = e;
6
- }, n = c.create();
7
- n.interceptors.request.use((e) => {
8
- o?.baseURL && (e.baseURL = o.baseURL);
9
- const t = o?.getToken?.();
10
- return t && (e.headers.Authorization = `Token ${t}`), e;
2
+ import { useQuery as p, useQueryClient as d, useMutation as h } from "@tanstack/react-query";
3
+ let r;
4
+ const m = (e) => {
5
+ r = e;
6
+ }, a = c.create();
7
+ a.interceptors.request.use((e) => {
8
+ r?.baseURL && (e.baseURL = r.baseURL), r?.headers && Object.entries(r.headers).forEach(([s, o]) => {
9
+ e.headers[s] = o;
10
+ });
11
+ const t = r?.getToken?.();
12
+ if (t) {
13
+ const s = r?.tokenType ?? "Bearer";
14
+ e.headers.Authorization = `${s} ${t}`;
15
+ }
16
+ return e;
11
17
  });
12
- n.interceptors.response.use(
13
- (e) => (o?.onSuccess?.(e.data), e),
18
+ a.interceptors.response.use(
19
+ (e) => (r?.onSuccess?.(e.data), e),
14
20
  (e) => {
15
21
  const t = e?.response?.status, s = {
16
22
  400: "Bad request. Please check your input.",
@@ -20,36 +26,36 @@ n.interceptors.response.use(
20
26
  409: "Conflict occurred. Please try again.",
21
27
  422: "Validation error. Please check the form.",
22
28
  500: "Server error. Please try again later."
23
- }, r = e?.response?.data?.message || t && o?.errorMessages?.[t] || t && s[t] || e?.message || "Network Error";
24
- return o?.toast?.error(r, o.toastOptions), o?.onError?.(e, r), t === 401 && o?.onLogout?.(), Promise.reject(e);
29
+ }, o = e?.response?.data?.message || t && r?.errorMessages?.[t] || t && s[t] || e?.message || "Network Error";
30
+ return r?.toast?.error(o, r.toastOptions), r?.onError?.(e, o), t === 401 && r?.onLogout?.(), Promise.reject(e);
25
31
  }
26
32
  );
27
33
  const u = {
28
- GET: (e, t) => n.get(e, { params: t }).then((s) => s.data),
29
- POST: (e, t) => n.post(e, t).then((s) => s.data),
30
- PATCH: (e, t) => n.patch(e, t).then((s) => s.data),
31
- DELETE: (e) => n.delete(e).then((t) => t.data)
34
+ GET: (e, t) => a.get(e, { params: t }).then((s) => s.data),
35
+ POST: (e, t) => a.post(e, t).then((s) => s.data),
36
+ PATCH: (e, t) => a.patch(e, t).then((s) => s.data),
37
+ DELETE: (e) => a.delete(e).then((t) => t.data)
32
38
  };
33
- function g(e, t, s, r, a) {
39
+ function y(e, t, s, o, n) {
34
40
  return p({
35
41
  queryKey: e,
36
- queryFn: () => u[t](s, r),
37
- ...a
42
+ queryFn: () => u[t](s, o),
43
+ ...n
38
44
  });
39
45
  }
40
- function y(e, t, s, r) {
41
- const a = d();
42
- return l({
46
+ function g(e, t, s) {
47
+ const o = d();
48
+ return h({
43
49
  mutationKey: e,
44
- mutationFn: (i) => u[t](s, i),
50
+ mutationFn: ({ endpoint: n, data: i }) => u[t](n, i),
45
51
  onSuccess: () => {
46
- r && a.invalidateQueries({ queryKey: r });
52
+ s && o.invalidateQueries({ queryKey: s });
47
53
  }
48
54
  });
49
55
  }
50
56
  export {
51
- n as api,
52
- h as setupApi,
53
- y as useApiMutation,
54
- g as useApiQuery
57
+ a as api,
58
+ m as setupApi,
59
+ g as useApiMutation,
60
+ y as useApiQuery
55
61
  };
@@ -1 +1 @@
1
- (function(s,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("axios"),require("@tanstack/react-query")):typeof define=="function"&&define.amd?define(["exports","axios","@tanstack/react-query"],r):(s=typeof globalThis<"u"?globalThis:s||self,r(s.ReactApiKit={},s.axios,s.reactQuery))})(this,(function(s,r,u){"use strict";let o;const d=e=>{o=e},i=r.create();i.interceptors.request.use(e=>{o?.baseURL&&(e.baseURL=o.baseURL);const t=o?.getToken?.();return t&&(e.headers.Authorization=`Token ${t}`),e}),i.interceptors.response.use(e=>(o?.onSuccess?.(e.data),e),e=>{const t=e?.response?.status,n={400:"Bad request. Please check your input.",401:"Session expired. Please login again.",403:"You do not have permission to perform this action.",404:"Requested resource not found.",409:"Conflict occurred. Please try again.",422:"Validation error. Please check the form.",500:"Server error. Please try again later."},a=e?.response?.data?.message||t&&o?.errorMessages?.[t]||t&&n[t]||e?.message||"Network Error";return o?.toast?.error(a,o.toastOptions),o?.onError?.(e,a),t===401&&o?.onLogout?.(),Promise.reject(e)});const p={GET:(e,t)=>i.get(e,{params:t}).then(n=>n.data),POST:(e,t)=>i.post(e,t).then(n=>n.data),PATCH:(e,t)=>i.patch(e,t).then(n=>n.data),DELETE:e=>i.delete(e).then(t=>t.data)};function f(e,t,n,a,c){return u.useQuery({queryKey:e,queryFn:()=>p[t](n,a),...c})}function l(e,t,n,a){const c=u.useQueryClient();return u.useMutation({mutationKey:e,mutationFn:y=>p[t](n,y),onSuccess:()=>{a&&c.invalidateQueries({queryKey:a})}})}s.api=i,s.setupApi=d,s.useApiMutation=l,s.useApiQuery=f,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(o,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("axios"),require("@tanstack/react-query")):typeof define=="function"&&define.amd?define(["exports","axios","@tanstack/react-query"],i):(o=typeof globalThis<"u"?globalThis:o||self,i(o.ReactApiKit={},o.axios,o.reactQuery))})(this,(function(o,i,u){"use strict";let n;const p=e=>{n=e},a=i.create();a.interceptors.request.use(e=>{n?.baseURL&&(e.baseURL=n.baseURL),n?.headers&&Object.entries(n.headers).forEach(([s,r])=>{e.headers[s]=r});const t=n?.getToken?.();if(t){const s=n?.tokenType??"Bearer";e.headers.Authorization=`${s} ${t}`}return e}),a.interceptors.response.use(e=>(n?.onSuccess?.(e.data),e),e=>{const t=e?.response?.status,s={400:"Bad request. Please check your input.",401:"Session expired. Please login again.",403:"You do not have permission to perform this action.",404:"Requested resource not found.",409:"Conflict occurred. Please try again.",422:"Validation error. Please check the form.",500:"Server error. Please try again later."},r=e?.response?.data?.message||t&&n?.errorMessages?.[t]||t&&s[t]||e?.message||"Network Error";return n?.toast?.error(r,n.toastOptions),n?.onError?.(e,r),t===401&&n?.onLogout?.(),Promise.reject(e)});const d={GET:(e,t)=>a.get(e,{params:t}).then(s=>s.data),POST:(e,t)=>a.post(e,t).then(s=>s.data),PATCH:(e,t)=>a.patch(e,t).then(s=>s.data),DELETE:e=>a.delete(e).then(t=>t.data)};function f(e,t,s,r,c){return u.useQuery({queryKey:e,queryFn:()=>d[t](s,r),...c})}function h(e,t,s){const r=u.useQueryClient();return u.useMutation({mutationKey:e,mutationFn:({endpoint:c,data:l})=>d[t](c,l),onSuccess:()=>{s&&r.invalidateQueries({queryKey:s})}})}o.api=a,o.setupApi=p,o.useApiMutation=h,o.useApiQuery=f,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "react-api-kit",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Reusable Axios + TanStack Query API hooks for React",
5
5
  "license": "ISC",
6
6
  "author": "Ajay kammar",
7
-
8
7
  "main": "./dist/react-api-kit.umd.js",
9
8
  "module": "./dist/react-api-kit.mjs",
10
9
  "types": "./dist/index.d.ts",
@@ -29,4 +28,4 @@
29
28
  "@vitejs/plugin-react": "^5.1.2",
30
29
  "vite": "^7.3.0"
31
30
  }
32
- }
31
+ }